Row
用于通用 @expo/ui 组件的水平布局容器。
For the complete documentation index, see llms.txt. Use this file to discover all available pages.
一个水平布局容器,从起始到结束排列其子元素。在 Android 上委托给 Jetpack Compose 的 Row,在 iOS 上委托给 SwiftUI 的 HStack,在 Web 上委托给 flex View。
安装
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
用法
基本行
import { Host, Row, Text } from '@expo/ui'; export default function RowExample() { return ( <Host matchContents> <Row spacing={8}> <Text>One</Text> <Text>Two</Text> <Text>Three</Text> </Row> </Host> ); }
对齐
使用 alignment 在交叉(垂直)轴上定位子元素。
import { Host, Row, Text } from '@expo/ui'; export default function RowAlignmentExample() { return ( <Host style={{ flex: 1 }}> <Row spacing={8} alignment="center"> <Text>居中</Text> <Text>居中</Text> </Row> </Host> ); }
使用 Spacer 拉开内容
将 Row 与可伸缩的 Spacer 配对,以将其子元素推到相对两端。
import { Host, Row, Text, Spacer } from '@expo/ui'; export default function RowSpacerExample() { return ( <Host style={{ flex: 1 }}> <Row> <Text>前导</Text> <Spacer flexible /> <Text>尾随</Text> </Row> </Host> ); }
API
import { Row } from '@expo/ui';
Component
A horizontal layout container that arranges its children from start to end.
Props for the Row component, a horizontal layout container.
string • Default: 'start'Cross-axis (vertical) alignment of children.
Acceptable values are: 'start' | 'center' | 'end'
booleanWhether the component is disabled. Disabled components do not respond to user interaction.
ModifierConfig[]Platform-specific modifier escape hatch. Pass an array of modifier configs
from @expo/ui/swift-ui/modifiers or @expo/ui/jetpack-compose/modifiers.
() => voidCalled when the component is removed from screen.
numberHorizontal spacing between children, in density-independent pixels.
Pick<ViewStyle, 'padding' | 'paddingHorizontal' | 'paddingVertical' | 'paddingTop' | 'paddingBottom' | 'paddingLeft' | 'paddingRight' | 'backgroundColor' | 'borderRadius' | 'borderWidth' | 'borderColor' | 'opacity' | 'width' | 'height'>Platform-agnostic style properties. These are translated to SwiftUI modifiers on iOS and Jetpack Compose modifiers on Android.