This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
间隔器
一个用于灵活间距的 SwiftUI Spacer 组件。
iOS
tvOS
Included in Expo Go
有关跨平台使用,请参阅通用的Spacer— 它会针对每个平台渲染相应的原生组件。
Expo UI Spacer 与官方 SwiftUI Spacer API 保持一致,并会扩展以填充堆栈中的可用空间。

安装
Terminal
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
用法
HStack 中的基础 Spacer
使用 Spacer 将内容推到水平堆栈的两端。
SpacerHStackExample.tsx
import { Host, HStack, Text, Spacer } from '@expo/ui/swift-ui'; export default function SpacerHStackExample() { return ( <Host style={{ flex: 1 }}> <HStack> <Text>Left</Text> <Spacer /> <Text>Right</Text> </HStack> </Host> ); }
VStack 中的基础 Spacer
使用 Spacer 将内容推到垂直堆栈的两端。
SpacerVStackExample.tsx
import { Host, VStack, Text, Spacer } from '@expo/ui/swift-ui'; export default function SpacerVStackExample() { return ( <Host style={{ flex: 1 }}> <VStack> <Text>Top</Text> <Spacer /> <Text>Bottom</Text> </VStack> </Host> ); }
API
import { Spacer } from '@expo/ui/swift-ui';
Component
Type: React.Element<SpacerProps>