<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ViewThatFits/init(in:content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12ViewThatFitsV2in7contentACyxGAA4AxisO3SetV_xyXEtcfc"
  },
  "title" : "init(in:content:)"
}
-->

# init(in:content:)

Produces a view constrained in the given axes from one of several
alternatives provided by a content builder.

```
nonisolated init(in axes: Axis.Set = [.horizontal, .vertical], @ContentBuilder content: () -> Content)
```

## Parameters

`axes`

A set of axes to constrain children to. The set may
contain [`Axis.horizontal`](/documentation/SwiftUI/Axis/horizontal), [`Axis.vertical`](/documentation/SwiftUI/Axis/vertical), or both of these.
`ViewThatFits` chooses the first child whose size fits within the
proposed size on these axes. If `axes` is an empty set,
`ViewThatFits` uses the first child view. By default,
`ViewThatFits` uses both axes.

`content`

A content builder that provides the child views for this
container, in order of preference. The builder chooses the first
child view that fits within the proposed width, height, or both,
as defined by `axes`.

---

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)