This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Section
用于在列表和表单中对内容进行分组的 SwiftUI Section 组件。
Expo UI Section matches the official 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
使用 title prop 创建带有文本标题的简单 Section。
自定义标题和页脚的 Section
使用 header 和 footer props 创建自定义视图。仅当未提供 title 时才会使用这些 props。
可折叠的 Section
使用 isExpanded prop 控制 Section 是展开还是折叠。提供该 prop 后,Section 将变为可折叠。使用 onIsExpandedChange 处理状态变化。
**注意:**可折叠的 Section 要求 iOS 17+ 和 tvOS 17+,并且列表必须使用
sidebar样式。可折叠的 Section 不支持页脚。
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.