shaffex

HStack is a view that arranges its children in a horizontal line. The alignment parameter determines how the views are aligned vertically.

Parameters:

alignment (optional) This parameter determines the vertical alignment of the views within the HStack. It’s of type VerticalAlignment and can take the following values:

Default value: center

spacing (optional) This parameter determines the horizontal spacing between the views.

Default value: System default spacing

Examples

Hstack example

<body>
    <hstack>
        <circle foregroundColor="red"/>
        <circle foregroundColor="green"/>
        <circle foregroundColor="blue"/>
    </hstack>
</body>

Screenshot


<body>
    <hstack spacing="0">
        <rectangle foregroundColor="red"/>
        <rectangle foregroundColor="green"/>
        <rectangle foregroundColor="blue"/>
    </hstack>
</body>

Screenshot


Example with various spacings

<body>
    <vstack>
        <text>spacing 0:</text>
        <hstack spacing="0">
            <rectangle foregroundColor="red"/>
            <circle foregroundColor="green"/>
            <rectangle foregroundColor="blue"/>
        </hstack>
        <text>spacing 20:</text>
        <hstack spacing="20">
            <rectangle foregroundColor="red"/>
            <circle foregroundColor="green"/>
            <rectangle foregroundColor="blue"/>
        </hstack>
        <text>spacing 100:</text>
        <hstack spacing="100">
            <rectangle foregroundColor="red"/>
            <circle foregroundColor="green"/>
            <rectangle foregroundColor="blue"/>
        </hstack>
    </vstack>
</body>

Screenshot


Example with various alignments

<body>
    <vstack>
        <text>top alignment:</text>
        <hstack alignment="top">
            <rectangle foregroundColor="red"/>
            <circle foregroundColor="green"/>
            <rectangle foregroundColor="blue"/>
        </hstack>
        <text>center alignment:</text>
        <hstack alignment="center">
            <rectangle foregroundColor="red"/>
            <circle foregroundColor="green"/>
            <rectangle foregroundColor="blue"/>
        </hstack>
        <text>bottom alignment:</text>
        <hstack alignment="bottom">
            <rectangle foregroundColor="red"/>
            <circle foregroundColor="green"/>
            <rectangle foregroundColor="blue"/>
        </hstack>
    </vstack>
</body>

Screenshot