Layout and lists

Stacks

VStack, HStack and ZStack lay native views out in a column, a row or layers.

iOSSwiftUI VStack, HStack, ZStackAndroidCompose Column, Row, BoxRenders in a Screen or an Island
Stacks on iOS
iOSSwiftUI VStack, HStack, ZStack
Stacks on Android
AndroidCompose Column, Row, Box

Import

ts
import {VStack, HStack, ZStack, Spacer, Divider} from '@hzblj/kara-ui'

VStack

Stacks its children top to bottom — SwiftUI VStack / Compose Column.

Also takes the native `sx` props.

PropTypeDefaultDescription
align'center' | 'end' | 'start''start'

The children's horizontal alignment. start by default.

childrenReactNode—

Laid out top to bottom, spacing apart.

onPress() => void—

Makes the whole stack pressable. iOS adds a tap gesture with no press feedback; Android a clickable whose ripple fills the stack's shape.

spacingSpaceSize—

The space between children.

testIDstring—

Test identifier, forwarded to the native view.

align'start'
'center' | 'end' | 'start'

The children's horizontal alignment. start by default.

children
ReactNode

Laid out top to bottom, spacing apart.

onPress
() => void

Makes the whole stack pressable. iOS adds a tap gesture with no press feedback; Android a clickable whose ripple fills the stack's shape.

spacing
SpaceSize

The space between children.

testID
string

Test identifier, forwarded to the native view.

HStack

A horizontal stack — SwiftUI HStack / Compose Row.

Also takes the native `sx` props.

PropTypeDefaultDescription
align'center' | 'end' | 'start''start'

How the children line up vertically — start is the top, end the bottom. start by default.

childrenReactNode—

Native views, laid out from the leading edge.

onPress() => void—

Makes the stack pressable — a tap gesture on iOS, a clickable with Material's ripple on Android.

spacingSpaceSize—

The gap between children. Unset, SwiftUI puts its default spacing between them and Compose none.

testIDstring—

Test identifier, forwarded to the native view.

align'start'
'center' | 'end' | 'start'

How the children line up vertically — start is the top, end the bottom. start by default.

children
ReactNode

Native views, laid out from the leading edge.

onPress
() => void

Makes the stack pressable — a tap gesture on iOS, a clickable with Material's ripple on Android.

spacing
SpaceSize

The gap between children. Unset, SwiftUI puts its default spacing between them and Compose none.

testID
string

Test identifier, forwarded to the native view.

ZStack

Layers its children on one another — SwiftUI ZStack / Compose Box.

Also takes the native `sx` props.

PropTypeDefaultDescription
align'bottom' | 'center' | 'top''center'

Where the children sit vertically; they are always centred horizontally. center by default.

childrenReactNode—

Drawn in order, the last on top.

onPress() => void—

Makes the whole stack pressable. iOS adds a tap gesture with no press feedback; Android a clickable whose ripple fills the stack's shape.

testIDstring—

Test identifier, forwarded to the native view.

align'center'
'bottom' | 'center' | 'top'

Where the children sit vertically; they are always centred horizontally. center by default.

children
ReactNode

Drawn in order, the last on top.

onPress
() => void

Makes the whole stack pressable. iOS adds a tap gesture with no press feedback; Android a clickable whose ripple fills the stack's shape.

testID
string

Test identifier, forwarded to the native view.

Spacer

Takes up the free space in a stack — SwiftUI Spacer / Compose Spacer with weight(1).

PropTypeDescription
minSpaceSize

The least room it takes. iOS holds it along the stack's axis; Android as a minimum height only.

testIDstring

iOS: forwarded to the native view. Android ignores it.

min
SpaceSize

The least room it takes. iOS holds it along the stack's axis; Android as a minimum height only.

testID
string

iOS: forwarded to the native view. Android ignores it.

Divider

A horizontal hairline — SwiftUI Divider / Compose HorizontalDivider.

PropTypeDefaultDescription
colorColorToken'border.tertiary'

The line's colour. border.tertiary by default.

testIDstring—

Test identifier, forwarded to the native view on iOS — Android ignores it.

color'border.tertiary'
ColorToken

The line's colour. border.tertiary by default.

testID
string

Test identifier, forwarded to the native view on iOS — Android ignores it.

Platform notes

  • Native stacks take the native sx surface: spacing rather than gap, wide and tall rather than flex.
  • A stack with onPress is pressable, and on Android its ripple covers the whole shape, padding included.
  • Spacer eats the free space; spacing is the fixed gap. A ZStack draws its last child on top.