Column

public struct Column : StackElement

Displays a list of items in a linear vertical layout.

  • Describes how the column’s children will be horizontally aligned.

    See more

    Declaration

    Swift

    public enum ColumnAlignment : Equatable
  • Declaration

    Swift

    public var children: [(element: Element, traits: StackLayout.Traits, key: AnyHashable?)]
  • Declaration

    Swift

    public private(set) var layout: StackLayout { get }
  • Declaration

    Swift

    public init()
  • Creates a Column, using result builder syntax. Columns display a list of items in a vertical stack.

    Column {
        Label(text: "Welcome")
    
        TextField(text: username)
        TextField(text: password)
    
        Button(
            onTap: handleSignIn,
            wrapping: Label(text: "Sign In")
        )
    }
    

    By default, each item in the column will be stretched or compressed with equal priority in the event of overflow or underflow. You can control this behavior by adding a stackLayoutChild modifier to an item.

    Column {
        ImportantHeader()
            .stackLayoutChild(priority: .fixed)
    
        LessImportantContent()
    }
    

    You can also use this modifier to add keys and alignment guides. See StackElement.add for more information.

    See Also

    StackElement.add()

    Declaration

    Swift

    public init(
        alignment: ColumnAlignment = .leading,
        underflow: StackLayout.UnderflowDistribution = .spaceEvenly,
        overflow: StackLayout.OverflowDistribution = .condenseProportionally,
        minimumSpacing: CGFloat = 0,
        @ElementBuilder<StackLayout.Child> elements: () -> [StackLayout.Child]
    )

    Parameters

    alignment

    Specifies how children will be aligned horizontally. Default: .leading

    underflow

    Determines the layout when there is extra free space available. Default: .spaceEvenly

    overflow

    Determines the layout when there is not enough space to fit all children as measured. Default: .condenseProportionally

    minimumSpacing

    Spacing in between elements. Default: 0

    elements

    A block containing all elements to be included in the stack.

  • Declaration

    Swift

    public var verticalUnderflow: StackLayout.UnderflowDistribution { get set }
  • Declaration

    Swift

    public var verticalOverflow: StackLayout.OverflowDistribution { get set }
  • Specifies how children will be aligned horizontally.

    Declaration

    Swift

    public var horizontalAlignment: ColumnAlignment { get set }
  • Declaration

    Swift

    public var minimumVerticalSpacing: CGFloat { get set }