跳到正文

Popover

从组合式 SwiftUI 触发器显示原生 SwiftUI 浮窗。

#导入

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

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

#用法

<Popover
  isPresented={open()}
  onIsPresentedChange={setOpen}
  attachmentAnchor="bottom"
  arrowEdge="top"
>
  <Popover.Trigger render={<Button label="Open" />} />
  <Popover.Content>
    <QuickGUIHostView width={280} height={120}>
      <SettingsPanel />
    </QuickGUIHostView>
  </Popover.Content>
</Popover>

#结构

  • Popover.Trigger
  • Popover.Content
<Popover isPresented={open()} onIsPresentedChange={setOpen}>
  <Popover.Trigger render={<Button label="Open" />} />
  <Popover.Content>{/* SwiftUI-hosted content */}</Popover.Content>
</Popover>

#API 参考

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

Popover(props: PopoverProps): NativeNode
testIDstring—

Stable identifier exposed to macOS accessibility and UI testing.

string
查看源码
modifiersViewModifier[]—

SwiftUI modifiers, applied in array order.

ViewModifier[]
查看源码
childrenunknown—

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

unknown
查看源码
isPresentedboolean—

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

boolean
查看源码
onIsPresentedChange(isPresented: boolean) => void—

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

(isPresented: boolean) => void
查看源码
attachmentAnchorPopoverAttachmentAnchor—

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

PopoverAttachmentAnchor
查看源码
arrowEdgePopoverArrowEdge—

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

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

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

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

Popover.Trigger

查看源码
Popover.Trigger(props: PopoverTriggerProps): NativeNode
renderJSX.Element—

Native SwiftUI component used as the trigger. This follows Base UI's composition shape: Trigger supplies behavior and `render` replaces its default element. The rendered component's own press handler runs before Trigger's behavior.

JSX.Element
查看源码
onPress(event: QuickGuiEvent) => void—

Called after the rendered component's own press handler and before the popover opens.

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

Receives the rendered trigger component rather than the internal structural slot.

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

Popover.Content

查看源码
Popover.Content(props: PopoverContentProps): NativeNode
childrenunknown—

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

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

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

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