This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
列表
用于显示可滚动项目列表的 SwiftUI List 组件。
如需跨平台使用,请参阅通用
List— 它会根据平台渲染相应的原生组件。
Expo UI List 与官方 SwiftUI List API 相匹配,并支持通过 listStyle 修饰符、各种行和分区修饰符,以及选择、重新排序和编辑功能进行样式设置。
List目前尚不支持延迟渲染行:React 会预先创建每一行,因此大型列表的挂载速度可能较慢。我们正在改进这一点。对于大型列表,我们建议使用 FlashList 或 Legend List。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
基本列表
带标签和图标的列表
列表样式
使用 listStyle 修饰符更改列表的外观。
Note: tvOS 不支持
inset、insetGrouped和sidebar样式。
选择和编辑模式
使用复合组件 List.ForEach 的 onDelete 和 onMove 属性启用列表项的选择、删除和重新排序。
- 使用
environment修饰符启用编辑模式 - 使用
tag修饰符标识项目 - 使用
selection属性控制所选项目 - 使用
moveDisabled和deleteDisabled修饰符,禁用单个项目上的这些操作
下拉刷新
使用 refreshable 修饰符启用下拉刷新功能。
行样式
使用 listRowBackground、listRowSeparator、listRowSeparatorTint 和 listRowInsets 修饰符自定义单个行。将 alignmentGuide 与 listRowSeparatorLeading 指引配合使用,可设置行分隔线的起始位置。
键盘关闭行为
使用 scrollDismissesKeyboard 修饰符控制滚动时键盘的关闭方式。
标题醒目程度
使用 headerProminence 修饰符调整分区标题的视觉醒目程度。
API
import { List } from '@expo/ui/swift-ui';
Components
Type: React.Element<ListProps>
A list component that renders its children using a native SwiftUI List.
Type: React.Element<ListForEachProps>
A compound component of List that enables item deletion and reordering.
This component must be used as a child of List (as List.ForEach).
(indices: number[]) => voidCallback triggered when items are deleted. Receives an array of indices that were deleted.
See: Official SwiftUI documentation.
(sourceIndices: number[], destination: number) => voidCallback triggered when items are moved. Receives the source indices and destination index.
See: Official SwiftUI documentation.