This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
分区
一个用于在列表和表单中对内容进行分组的 SwiftUI Section 组件。
Expo UI 的 Section 与官方 SwiftUI Section API 保持一致,用于在 List、Form 或 Picker 组件中对相关内容进行分组。


安装
If you are installing this in an existing React Native app, make sure to install expo in your project.
用法
带标题的基础 Section
对简单的、带文本标题的 Section 使用 title 属性。
带自定义页眉和页脚的 Section
对自定义视图使用 header 和 footer 属性。只有在未提供 title 时才会使用这些属性。
可折叠 Section
使用 isExpanded 属性来控制 Section 是展开还是折叠。提供该属性后,Section 就会变成可折叠的。使用 onIsExpandedChange 处理状态变化。
注意: 可折叠 Section 需要 iOS 17+ 和 tvOS 17+,且列表必须使用
sidebar样式。可折叠 Section 不支持 footer。
Form 中的多个 Section
Section 可用于 Form 组件中,将表单控件组织为逻辑分组。
API
import { Section } from '@expo/ui/swift-ui';
Component
Type: React.Element<SectionProps>
Section component uses the native Section component.
booleanControls whether the section is expanded or collapsed. When provided, the section becomes collapsible.
Note: Available only when the list style is set to
sidebar.
(isExpanded: boolean) => voidCallback triggered when the section's expanded state changes.