This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

排

用于通用 @expo/ui 组件的水平布局容器。

Android
iOS
Web
Included in Expo Go
Recommended version:
~58.0.15

一个水平布局容器,将其子元素从开始排列到结束。在 Android 上委托给 Jetpack Compose 的 Row,在 iOS 上委托给 SwiftUI 的 HStack,在 Web 上使用 flex View。

🌐 A horizontal layout container that arranges its children from start to end. Delegates to Jetpack Compose's Row on Android, SwiftUI's HStack on iOS, and a flex View on web.

Three colored boxes laid out horizontally inside a RowThree colored boxes laid out horizontally inside a Row

安装

🌐 Installation

Terminal
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

用法

🌐 Usage

基础划船

🌐 Basic row

RowExample.tsx
import { useColorScheme } from 'react-native'; import { Host, Row, Text } from '@expo/ui'; export default function RowExample() { const colorScheme = useColorScheme(); const ink = { color: colorScheme === 'dark' ? '#FFFFFF' : '#000000' }; return ( <Host matchContents> <Row spacing={8}> <Text textStyle={ink}>One</Text> <Text textStyle={ink}>Two</Text> <Text textStyle={ink}>Three</Text> </Row> </Host> ); }

对齐

🌐 Alignment

使用 alignment 将子元素沿交叉(垂直)轴定位。

🌐 Use alignment to position children along the cross (vertical) axis.

RowAlignmentExample.tsx
import { useColorScheme } from 'react-native'; import { Host, Row, Text } from '@expo/ui'; export default function RowAlignmentExample() { const colorScheme = useColorScheme(); const ink = { color: colorScheme === 'dark' ? '#FFFFFF' : '#000000' }; return ( <Host style={{ width: '100%', height: 160 }}> <Row spacing={8} alignment="center"> <Text textStyle={{ ...ink, fontSize: 30 }}>Large</Text> <Text textStyle={ink}>centered</Text> </Row> </Host> ); }

使用 Spacer 推开内容

🌐 Pushing content apart with Spacer

将 Row 与一个灵活的 Spacer 配对,以将其子元素推到相对两端。

🌐 Pair Row with a flexible Spacer to push its children to the opposite ends.

RowSpacerExample.tsx
import { useColorScheme } from 'react-native'; import { Host, Row, Text, Spacer } from '@expo/ui'; export default function RowSpacerExample() { const colorScheme = useColorScheme(); const ink = { color: colorScheme === 'dark' ? '#FFFFFF' : '#000000' }; return ( <Host matchContents={{ vertical: true }} style={{ width: '100%' }}> <Row> <Text textStyle={ink}>Leading</Text> <Spacer flexible /> <Text textStyle={ink}>Trailing</Text> </Row> </Host> ); }

应用接口

🌐 API

import { Row } from '@expo/ui';

No API data file found, sorry!