<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/fixedSize(horizontal:vertical:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE9fixedSize10horizontal8verticalQrSb_SbtF"
  },
  "title" : "fixedSize(horizontal:vertical:)"
}
-->

# fixedSize(horizontal:vertical:)

Fixes this view at its ideal size in the specified dimensions.

```
nonisolated func fixedSize(horizontal: Bool, vertical: Bool) -> some View
```

## Parameters

`horizontal`

A Boolean value that indicates whether to fix the width
of the view.

`vertical`

A Boolean value that indicates whether to fix the height
of the view.

## Return Value

A view that fixes this view at its ideal size in the
dimensions specified by `horizontal` and `vertical`.

## Discussion

This function behaves like [`fixedSize()`](/documentation/SwiftUI/View/fixedSize()), except with
`fixedSize(horizontal:vertical:)` the fixing of the axes can be
optionally specified in one or both dimensions. For example, if you
horizontally fix a text view before wrapping it in the frame view,
you’re telling the text view to maintain its ideal *width*. The view
calculates this to be the space needed to represent the entire string.

```
Text("A single line of text, too long to fit in a box.")
    .fixedSize(horizontal: true, vertical: false)
    .frame(width: 200, height: 200)
    .border(Color.gray)
```

This can result in the view exceeding the parent’s bounds, which may or
may not be the effect you want.

![A screenshot showing a text view exceeding the bounds of its](images/com.apple.SwiftUI/SwiftUI-View-fixedSize-3@2x.png)

---

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)