One Logo Pool Ball
wwwwwwwwwwwwwwwwwww

iOS Stacks

Host, HStack, VStack, ZStack, Spacer, and Slot under One.iOS

One.iOS HStack, VStack, ZStack, and Spacer laying out SwiftUI views in a card

SwiftUI stack layout under One.iOS.

Usage

import { One } from 'one'
<One.iOS.VStack spacing={8} style={{ width: '100%' }}>
<One.iOS.HStack>
<One.iOS.Label label="Wi-Fi" systemImage="wifi" />
<One.iOS.Spacer />
<One.iOS.Text text="Home" />
</One.iOS.HStack>
<One.iOS.ProgressView value={0.4} />
</One.iOS.VStack>

Greedy containers take the box they are given instead of reporting an ideal height, so they cannot be children of a stack: Form, List, ScrollView, Tabs, Pager, and NavigationStack each need their own box.

Host, HStack, VStack

One.iOS.Host lays children along axis. One.iOS.HStack is always horizontal and One.iOS.VStack always vertical; both take the same props without axis. Children that are not SwiftUI views render through React Native inside the stack.

PropsTypeDescription
axisHostAxis = "vertical"vertical or horizontal. Host only.
HostAxis = "vertical"vertical or horizontal. Host only.
spacingnumber = 0The gap between children. Must be zero or more.
number = 0The gap between children. Must be zero or more.
alignmentHostAlignment = "leading"leading, center, or trailing.
HostAlignment = "leading"leading, center, or trailing.
children (required)ReactNodeSwiftUI views or React Native views.
ReactNodeSwiftUI views or React Native views.

Environment

Host, HStack, VStack, and Form apply these to their whole subtree.

EnvironmentTypeDescription
colorSchemeColorSchemelight or dark.
ColorSchemelight or dark.
dynamicTypeSizeDynamicTypeSizexSmall through xxxLarge, or accessibility1 through accessibility5.
DynamicTypeSizexSmall through xxxLarge, or accessibility1 through accessibility5.
controlSizeControlSizemini, small, regular, large, or extraLarge.
ControlSizemini, small, regular, large, or extraLarge.
localestringA non-empty locale identifier, such as fr_FR.
stringA non-empty locale identifier, such as fr_FR.
tintColorValueThe accent color for controls.
ColorValueThe accent color for controls.
isEnabledbooleanfalse disables every control inside.
booleanfalse disables every control inside.

On an iOS 27 simulator, a bordered prominent Button inside Host controlSize grew when the value changed from mini to extraLarge and returned to its original height when restored.

ZStack

One.iOS.ZStack layers children and takes the size of the largest one. alignment places the smaller children within it.

PropsTypeDescription
alignmentZStackAlignment = "center"topLeading, top, topTrailing, leading, center, trailing, bottomLeading, bottom, or bottomTrailing.
ZStackAlignment = "center"topLeading, top, topTrailing, leading, center, trailing, bottomLeading, bottom, or bottomTrailing.
children (required)ReactNodeThe layers, back to front.
ReactNodeThe layers, back to front.

Spacer

One.iOS.Spacer expands along its stack’s axis and pushes its neighbors apart. It must be inside a stack or another native container.

PropsTypeDescription
minLengthnumber = 0The least space it leaves. Must be zero or more.
number = 0The least space it leaves. Must be zero or more.

Slot

One.iOS.Slot reserves a fixed box inside a native container, for React Native content a measured parent cannot size.

PropsTypeDescription
height (required)numberThe box height. Must be above zero.
numberThe box height. Must be above zero.
widthnumber = 0The box width. 0 fills the width offered; inside an HStack, set one.
number = 0The box width. 0 fills the width offered; inside an HStack, set one.
children (required)ReactNodeThe React Native content.
ReactNodeThe React Native content.

Edit this page on GitHub.