<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentValues/buttonSizing",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesV12buttonSizingAA06ButtonF0Vvp"
  },
  "title" : "buttonSizing"
}
-->

# buttonSizing

The preferred sizing behavior of buttons in the view hierarchy.

```
var buttonSizing: ButtonSizing { get }
```

## Discussion

Views may use the specified button sizing when determining the size they
choose to be in their primary axis within their parent view’s proposed
size.

Use [`buttonSizing(_:)`](/documentation/SwiftUI/View/buttonSizing(_:)) to set the preferred sizing behavior
in the environment. Many built-in controls that display as a button
adapt to this environment value. You can read the environment value in
your own views and styles as well to adapt to the preferred sizing.

```
struct CustomButtonStyle: ButtonStyle {
    @Environment(\.buttonSizing) private var buttonSizing

    private var maxWidth: CGFloat {
        switch buttonSizing {
        case .flexible: .infinity
        case .fitted, _: nil
        }
    }

    func makeBody(configuration: Configuration) -> some View {
        configuration.content
            .frame(maxWidth: maxWidth)
            .background(.tint, in: Capsule())
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)