Interactive previews iPhone

ViewThatFits Vertical

A view that adapts to the available vertical space by providing the first child view that fits.

ViewThatFits Vertical - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview

Platform Compatibility

iOS 16.0+ iPadOS 16.0+ macOS 13.0+ watchOS 9.0+ tvOS 16.0+ visionOS 1.0+

Tags

SwiftUI Code

Docs
var body: some View {
  VStack(alignment: .leading) {
    testContent
      .background(.red)
      .frame(maxWidth: 200)
    testContent
      .background(.red.secondary)
      .frame(maxHeight: 20)
    testContent
      .background(.red.tertiary)
      .frame(maxHeight: 9)
  }
}

@ViewBuilder
var testContent: some View {
  ViewThatFits(in: .vertical) {
    Text("Size w300 h30")
      .frame(width: 300, height: 30)
      .foregroundStyle(.white)
    Text("Size w200 h20")
      .frame(width: 200, height: 20)
      .foregroundStyle(.white)
    Text("Fallback")
      .frame(width: 80, height: 10)
      .foregroundStyle(.white)
  }
}

Found an issue or have a suggestion?

Created: May 29, 2025Updated: May 31, 2025
Connect Wizard

Connect Wizard

Unlock insights App Store Connect doesn’t show you.

Get Started

More ViewThatFits Components

View all
ViewThatFits - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview
initializer

ViewThatFits

A view that adapts to the available space by providing the first child view that fits.

Explore Other Components

Browse all
Background Extension Effect - iPadOS - Landscape - Liquid Glass - Light Mode - Preview
modifier

Background Extension Effect

Adds the background extension effect to the view. The view will be duplicated into mirrored copies which will be placed around the view on any edge with available safe area. Additionally, a blur effect will be applied on top to blur out the copies

Toggle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Toggle

Creates a toggle with title, image, systemImage, and custom label.

StepperFieldDatePickerStyle - macOS - Flat Design - Light Mode - Preview
style

StepperFieldDatePickerStyle

A system style that displays the components in an editable field, with adjoining stepper that can increment/decrement the selected component

Slider Color - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

Slider Color

Customizing the color of the slider

DatePicker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

DatePicker

Creates an instance that selects a Date with an unbounded range

Min Max Current Value Gauge - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Min Max Current Value Gauge

Creates a gauge showing a value within a range and describes the gauge’s current, minimum, and maximum values

Future DatePicker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Future DatePicker

Creates an instance that selects a Date in a closed range

Picker Section - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
content

Picker Section

A Section inside a Picker