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— 它会为每个平台渲染相应的原生组件。
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 修饰符来更改列表的外观。
注意:
inset、insetGrouped和sidebar样式在 tvOS 上不可用。
选择与编辑模式
使用带有 onDelete 和 onMove 属性的 List.ForEach 复合组件,可启用列表项的选择、删除和重新排序。
- 使用
environment修饰符启用编辑模式 - 使用
tag修饰符标识项目 - 使用
selection属性控制选中的项目 - 使用
moveDisabled和deleteDisabled修饰符,禁用单个项目的移动和删除操作
下拉刷新
使用 refreshable 修饰符启用下拉刷新功能。
行样式
使用 listRowBackground、listRowSeparator 和 listRowInsets 修饰符来自定义单独的行。
键盘收起行为
使用 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.