---
title: "init(in:content:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/viewthatfits/init(in:content:)"
---

# init(in:content:)

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

## Declaration

```swift
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 doc://com.apple.SwiftUI/documentation/SwiftUI/Axis/horizontal, doc://com.apple.SwiftUI/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.
