跳到正文

Button

原生 SwiftUI 按钮,支持文本、SF Symbol、语义角色和按下处理。

#导入

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

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

#用法

<Host matchContents>
  <Button
    label="Continue"
    systemImage="arrow.right"
    onPress={continueFlow}
  />
</Host>

#API 参考

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

Button(props: ButtonProps): NativeNode
testIDstring—

Stable identifier exposed to macOS accessibility and UI testing.

string
查看源码
modifiersViewModifier[]—

SwiftUI modifiers, applied in array order.

ViewModifier[]
查看源码
labelstring—

The text label for a simple button.

string
查看源码
systemImagestring—

An SF Symbols name shown beside `label`.

string
查看源码
roleButtonRole—

Semantic SwiftUI button role.

ButtonRole
查看源码
onPress(event: QuickGuiEvent) => void—

Called when the native SwiftUI button is pressed.

(event: QuickGuiEvent) => void
查看源码
targetstring—

Identifier reserved for widget and live-activity button targets.

string
查看源码
childrenunknown—

Optional nested text used as the label when `label` is omitted.

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

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

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