跳到正文

SegmentedControl

原生分段选择器,支持值选择和中性的 Xcode 风格标签页角色。

#导入

从 @quickgui/solid/swift-ui 导入 SegmentedControl。

import { Host, SegmentedControl } from "@quickgui/solid/swift-ui";

#用法

<Host matchContents>
  <SegmentedControl
    role="tabs"
    selection={layout()}
    options={[
      { value: "list", label: "List" },
      { value: "grid", label: "Grid" },
    ]}
    onSelectionChange={setLayout}
  />
</Host>

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

SegmentedControl

查看源码
SegmentedControl(props: SegmentedControlProps): NativeNode
testIDstring—

Stable identifier exposed to macOS accessibility and UI testing.

string
查看源码
modifiersViewModifier[]—

SwiftUI modifiers, applied in array order.

ViewModifier[]
查看源码
selectionstring—

Controlled selected option value.

string
查看源码
optionsreadonly PickerOption[]—

Declares options. Reactive JSX expressions update this property in place.

readonly PickerOption[]
查看源码
labelstring—

Declares label (optional). Reactive JSX expressions update this property in place.

string
查看源码
onSelectionChange(selection: string, event: QuickGuiEvent) => void—

Declares onSelectionChange (optional). Reactive JSX expressions update this property in place.

(selection: string, event: QuickGuiEvent) => void
查看源码
ref((node: NativeNode) => void) | NativeNode—

Declares ref (optional). Reactive JSX expressions update this property in place.

((node: NativeNode) => void) | NativeNode
查看源码
roleSegmentedControlRole—

Use `tabs` for Xcode-style neutral segmented tab navigation on macOS 27.

SegmentedControlRole
查看源码