Contents

splitArrangementAxis

The axis of the split for a view within a split arrangement view.

Declaration

var splitArrangementAxis: Axis? { get set }

Discussion

Use this value to read the axis that a split arrangement is using to place its views. Views can adapt their layout or appearance based on whether the split is horizontal or vertical. The value is nil when the view is not contained within a split arrangement view.

struct DetailsView: View {
    @Environment(\.splitArrangementAxis) var axis

    var body: some View {
        let layout: AnyLayout = axis == .horizontal
            ? AnyLayout(VStackLayout())
            : AnyLayout(HStackLayout())
        layout {
            Artwork()
            Metadata()
        }
    }
}

See Also

Arrangement views