跳到正文

Toggle

受控的原生 SwiftUI 开关。

#导入

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

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

#用法

<Host matchContents>
  <Toggle
    label="Notifications"
    isOn={notifications()}
    onIsOnChange={setNotifications}
  />
</Host>

#API 参考

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

Toggle(props: ToggleProps): NativeNode
testIDstring—

Stable identifier exposed to macOS accessibility and UI testing.

string
查看源码
modifiersViewModifier[]—

SwiftUI modifiers, applied in array order.

ViewModifier[]
查看源码
isOnboolean—

Controlled SwiftUI `isOn` value.

boolean
查看源码
labelstring—

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

string
查看源码
onIsOnChange(isOn: boolean, event: QuickGuiEvent) => void—

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

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

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

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