Reference version

This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

ControlGroup

用于对交互式控件进行分组的 SwiftUI ControlGroup 组件。

iOS
tvOS
Included in Expo Go
Recommended version:
~58.0.1

Expo UI ControlGroup 与官方 SwiftUI ControlGroup API 相对应。放在 Menu 中时,子元素会显示为一行紧凑的水平按钮。

打开的 Menu,其中显示一行包含 Add、Favorite 和 Share 图标按钮的 ControlGroup,下方是 Rename 和 Delete 条目打开的 Menu,其中显示一行包含 Add、Favorite 和 Share 图标按钮的 ControlGroup,下方是 Rename 和 Delete 条目

安装

Terminal
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

用法

基本控制组

菜单中的控制组会显示为一行水平排列的图标按钮。

BasicControlGroupExample.tsx
import { Host, Menu, ControlGroup, Button, } from '@expo/ui/swift-ui'; export default function BasicControlGroupExample() { return ( <Host style={{ flex: 1 }}> <Menu label="Options" systemImage="ellipsis.circle"> <ControlGroup> <Button systemImage="plus" label="Add" onPress={() => console.log('Add')} /> <Button systemImage="star" label="Favorite" onPress={() => console.log('Favorite')} /> <Button systemImage="square.and.arrow.up" label="Share" onPress={() => console.log('Share')} /> </ControlGroup> <Button label="Other Action" onPress={() => console.log('Other')} /> </Menu> </Host> ); }

API

import { ControlGroup } from '@expo/ui/swift-ui';

Component

ControlGroup

iOS
tvOS

Type: React.Element<ControlGroupProps>

ControlGroupProps

children

iOS
tvOS 17.0+
Type: ReactNode

The control group's content. Can contain Button, Toggle, Picker, or other interactive controls.

label

iOS 16.0+
tvOS 17.0+
Optional • Type: ReactNode

The label for the control group. Can be a string for simple text labels, or a Label component for custom label content. When omitted, the control group has no label.

systemImage

iOS 16.0+
tvOS 17.0+
Optional • Type: SFSymbols7_0

An SF Symbol name to display alongside the label. Only used when label is a string.