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.
用法
带标题的基本部分
对于带文本标题的简单部分,请使用 title 属性。
带自定义页眉和页脚的 Section
对于自定义视图,请使用 header 和 footer 属性。只有在未提供 title 时才会使用这些属性。
可折叠部分
使用 isExpanded 属性来控制该部分是展开还是折叠。提供该属性后,此部分将变为可折叠。使用 onIsExpandedChange 来处理状态变化。
注意: 可折叠部分需要 iOS 17+ 和 tvOS 17+,并且列表必须使用
sidebar样式。可折叠部分不支持页脚。
表单中的多个部分
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.