Components
VStack
A SwiftUI VStack component for vertical layouts. Also called Column (Universal).
Expo UI VStack matches the official SwiftUI VStack API and arranges its children vertically.
Usage
Basic vertical stack
import { Host, VStack, Text } from '@expo/ui/swift-ui';
export default function BasicVStackExample() {
// Give the host a size when the stack needs room to align its children.
return (
<Host style={{ flex: 1 }}>
<VStack spacing={12}>
<Text>First</Text>
<Text>Second</Text>
<Text>Third</Text>
</VStack>
</Host>
);
}With alignment
The alignment prop controls horizontal alignment of children. Available options are: leading, center, and trailing.
import { Host, VStack, Rectangle } from '@expo/ui/swift-ui';
import { frame } from '@expo/ui/swift-ui/modifiers';
export default function VStackAlignmentExample() {
return (
<Host style={{ flex: 1 }}>
<VStack spacing={12} alignment="leading">
<Rectangle modifiers={[frame({ width: 50, height: 50 })]} />
<Rectangle
modifiers={[frame({ width: 100, height: 50 })]}
/>
<Rectangle modifiers={[frame({ width: 75, height: 50 })]} />
</VStack>
</Host>
);
}API
import { VStack } from '@expo/ui/swift-ui';Component
VStack
Type: React.Element<VStackProps>
VStackProps
alignment
Optional • Literal type: string
The horizontal alignment of children within the stack.
Acceptable values are: 'center' | 'leading' | 'trailing'
children
Type: ReactNode
spacing
Optional • Type: number
The spacing between children.
Inherited props
Modifiers
Use these modifiers in the modifiers prop of the SwiftUI and Universal version.
Modifiers for VStack
scrollTargetLayoutiOS 17+
Modifiers for any view
accessibilityAddTraitsaccessibilityElementaccessibilityHiddenaccessibilityHintaccessibilityIdentifieraccessibilityInputLabelsaccessibilityLabelaccessibilityRemoveTraitsaccessibilityValueactivityBackgroundTintalignmentGuideallowsTighteninganimationaspectRatiobackgroundbackgroundOverlayblurboldborderbrightnessclippedclipShapecolorInvertcontainerBackgroundcontainerRelativeFrameiOS 17+containerShapecontentShapecontentTransitioniOS 16+contrastcornerRadiuscreateModifierdisableddynamicTypeSizeenvironmentfixedSizefontforegroundColorforegroundStyleframegeometryGroupiOS 17+glassEffectglassEffectIdgrayscalegridCellAnchoriOS 16+gridCellColumnsgridCellUnsizedAxesgridColumnAlignmentiOS 16+hiddenhueRotationidignoreSafeAreaimageScaleinvalidatableContentiOS 17+italickerninglayoutPrioritylineHeightiOS 26+lineLimitlineSpacingluminanceToAlphamaskmatchedGeometryEffectminimumScaleFactormonospacedDigitmultilineTextAlignmentoffsetonAppearonDisappearonGeometryChangeonLongPressGestureonTapGestureopacityoverlaypaddingprivacySensitiveredactedrotation3DEffectrotationEffectsaturationscaleEffectshadowstrikethroughstrokeBordertextCasetinttruncationModeunderlineunredactedwidgetURLzIndex
Sources
The original Expo docs for this page:
- VStack (SwiftUI) (
source-of-truth/versions/v57.0.0/sdk/ui/swift-ui/vstack.md) - VStack (Universal) (
source-of-truth/versions/v57.0.0/sdk/ui/universal/column.md)