Components
VStack
Arrange children vertically with configurable spacing and horizontal alignment.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Default
Loading preview…
Code
'use client';
import { Text } from '@swiftuijs/ui';
import { VStack } from '@swiftuijs/ui';
export default function Example() {
return (<VStack>{(<>
<Text>First</Text>
<Text>Second</Text>
<Text>Third</Text>
</>)}</VStack>);
}Usage and limitations
alignmentisleading,center, ortrailing; omitted alignment stretches children across the container;spacingapplies between adjacent children.- Compose with
HStackorZStack;Spacerdistributes available vertical space. - Allow the container and children to shrink on narrow screens; long content may need
ScrollView. - For long scrolling lists, use
LazyVStackand review its virtualization requirements.
More examples
Spacing
Leading Alignment
Center Alignment
Trailing Alignment
With Spacer
With Buttons
Complex Layout
API reference
| Prop | Type | Required | Description |
|---|---|---|---|
alignment | EAlignment | No | The guide for aligning the subviews in this stack.
This guide has the same horizontal screen coordinate for every child view. Default: undefined (uses container default) |
spacing | number | string | No | The distance between adjacent subviews, in pixels.
If nil, the stack chooses a default distance for each pair of subviews. Default: 0 |
Inherits additional props from IBaseComponent.