跳到正文

Picker

受控的 SwiftUI 选择器,支持菜单、分段、单选组和内联样式。

#导入

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

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

#用法

<Host matchContents>
  <Picker
    label="Theme"
    selection={theme()}
    options={[
      { value: "system", label: "System" },
      { value: "light", label: "Light" },
      { value: "dark", label: "Dark" },
    ]}
    style="menu"
    onSelectionChange={setTheme}
  />
</Host>

#API 参考

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

Picker(props: PickerProps): 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
查看源码
stylePickerStyle—

Layout, typography, paint, and interaction-state styles. Arrays merge left to right.

PickerStyle
查看源码
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
查看源码