Reference version

ControlGroup

一个用于分组交互式控件的 SwiftUI ControlGroup 组件。

iOS
tvOS
Included in Expo Go
Bundled version:
~56.0.6

For the complete documentation index, see llms.txt. Use this file to discover all available pages.

Expo UI ControlGroup 与官方 SwiftUI ControlGroup API 一致。放置在 Menu 内时,子项会以紧凑的水平按钮行形式渲染。

一个打开的菜单,显示一行 ControlGroup,由“添加”“收藏”“分享”图标按钮组成,位于“重命名”和“删除”条目上方

注意: 在 tvOS 上,ControlGroup 需要 tvOS 17.0 或更高版本。

安装

Terminal
npx 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 matchContents> <Menu label="选项" systemImage="ellipsis.circle"> <ControlGroup> <Button systemImage="plus" label="添加" onPress={() => console.log('Add')} /> <Button systemImage="star" label="收藏" onPress={() => console.log('Favorite')} /> <Button systemImage="square.and.arrow.up" label="分享" onPress={() => console.log('Share')} /> </ControlGroup> <Button label="其他操作" 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.