An array of alternative layouts, ordered from most preferred to least preferred. The first child that fits in the available space is rendered.
Configuration options.
Support
Usage
Responsive layout
Provide a wide layout and a narrow fallback. ViewThatFits selects the first one that fits:Horizontal axis only
Test fit only along the horizontal axis:Adaptive button bar
Notes
- Children are tested in order. The first child whose ideal size fits within the available space is rendered. All others are discarded.
- If no child fits, the last child is used as the fallback.
- This is useful for building responsive layouts that adapt to different screen sizes without using GeometryReader.
See Also
- GeometryReader — manual geometry-based layout
- HStack — horizontal layout
- VStack — vertical layout