Components
HStack
Arrange children in a horizontal row with configurable spacing and vertical 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 { HStack } from '@swiftuijs/ui';
export default function Example() {
return (<HStack>{(<>
<Text>Left</Text>
<Text>Center</Text>
<Text>Right</Text>
</>)}</HStack>);
}Usage and limitations
alignmentistop,center(default), orbottom;spacingapplies between adjacent children.- Compose with
VStackorZStack;Spacerdistributes available horizontal space. - Children do not wrap automatically. Add
style={{ flexWrap: 'wrap' }}or switch layouts for narrow containers. - For long scrolling lists, use
LazyHStackand 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 vertical screen coordinate for every child view. Default: 'center' |
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.