Contents

VStack

A view that arranges its subviews in a vertical line.

Declaration

@frozen struct VStack<Content> where Content : View

Mentioned in

Overview

Unlike LazyVStack, which only renders the views when your app needs to display them, a VStack renders the views all at once, regardless of whether they are on- or offscreen. Use the regular VStack when you have a small number of subviews or don’t want the delayed rendering behavior of the “lazy” version.

The following example shows a simple vertical stack of 10 text views:

var body: some View {
    VStack(
        alignment: .leading,
        spacing: 10
    ) {
        ForEach(
            1...10,
            id: \.self
        ) {
            Text("Item \($0)")
        }
    }
}

[Image]

Topics

Creating a stack

See Also

Statically arranging views in one dimension