Popover
呼び出し側がスタイルした内容を、現在のウィンドウ内でアンカーの横に配置します。
デモを読み込み中…
let popover = Popover::new("help-trigger", "help-popup", open)
.side(AnchorSide::Bottom)
.side_offset(8.0);
let mut root = popover.root().child(
popover.trigger().on_click(toggle).child("Account"),
);
if popover.is_open() {
root = root.child(popover.positioner().child(
popover.popup().w(240.0).p(16.0).on_dismiss(dismiss).children([
popover.title().child("Account"),
popover.description().child("Manage your account settings."),
popover.close("Close").on_click(dismiss).child("Done"),
]),
));
}
root#インポート
quickgui から Popover をインポートします。
use quickgui::*;#使い方
let popover = Popover::new("help-trigger", "help-popup", open)
.side(AnchorSide::Bottom)
.side_offset(8.0);
let mut root = popover.root().child(
popover.trigger().on_click(toggle).child("Account"),
);
if popover.is_open() {
root = root.child(popover.positioner().child(
popover.popup().w(240.0).p(16.0).on_dismiss(dismiss).children([
popover.title().child("Account"),
popover.description().child("Manage your account settings."),
popover.close("Close").on_click(dismiss).child("Done"),
]),
));
}
root#構成
Popover::rootPopover::triggerPopover::surfacePopover::portalPopover::backdropPopover::positionerPopover::popupPopover::arrowPopover::viewportPopover::titlePopover::descriptionPopover::close
#API リファレンス
項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。
Popover
ソースを見るpub fn new( trigger_id: impl Into<ElementId>, surface_id: impl Into<ElementId>, open: bool, ) -> Selfopenpub const fn open(mut self, open: bool) -> Self—
Replace the controlled open flag, Base UI's Root `open` prop. The descriptor is copied per frame, so a component that retains the open flag itself can build one descriptor at construction time and stamp the current value onto it here.
pub const fn open(mut self, open: bool) -> Selfソースを見るkindpub const fn kind(mut self, kind: PopoverKind) -> Self—
placementpub const fn placement(mut self, placement: AnchorPlacement) -> Self—
Configures placement for this part.
pub const fn placement(mut self, placement: AnchorPlacement) -> Selfソースを見るsidepub const fn side(self, side: AnchorSide) -> Self—
Prefer one side of the anchor, keeping the current cross-axis alignment. This is the side half of [`Self::placement`], matching Base UI's `side` prop. A side is a preference: QuickGUI flips to the opposite side when the preferred one does not fit, and [`Self::resolved_side`] reports what actually happened.
pub const fn side(self, side: AnchorSide) -> Selfソースを見るalignpub const fn align(self, align: AnchorAlign) -> Self—
Prefer a cross-axis alignment, keeping the current side. This is the alignment half of [`Self::placement`], matching Base UI's `align` prop.
pub const fn align(self, align: AnchorAlign) -> Selfソースを見るside_offsetpub fn side_offset(self, offset: f32) -> Self—
Set the distance between the anchor and the positioner, Base UI's `sideOffset`. This is the Base UI-named alias of [`Self::anchor_gap`]. Both names stay supported and write the same bounded value.
pub fn side_offset(self, offset: f32) -> Selfソースを見るalign_offsetpub fn align_offset(mut self, offset: f32) -> Self—
Shift the popover along its cross axis before collision handling, Base UI's `alignOffset`. Positive values move right on a top or bottom placement and down on a left or right placement. The shift runs before the surface is clamped into the viewport, so it can slide a popup along its trigger but never push it off screen.
pub fn align_offset(mut self, offset: f32) -> Selfソースを見るcollision_paddingpub fn collision_padding(self, padding: f32) -> Self—
Set the collision padding kept inside the window viewport, Base UI's `collisionPadding`. This is the Base UI-named alias of [`Self::viewport_margin`]. Both names stay supported.
pub fn collision_padding(self, padding: f32) -> Selfソースを見るstickypub const fn sticky(mut self, sticky: bool) -> Self—
Choose whether the popover is kept inside the collision viewport, Base UI's `sticky`. QuickGUI keeps anchored surfaces on screen by default, which is Base UI's sticky behavior. Passing `false` locks the popover to its anchor so it travels off screen with a scrolling row instead of detaching from it.
pub const fn sticky(mut self, sticky: bool) -> Selfソースを見るanchor_elementpub fn anchor_element(mut self, anchor: impl Into<ElementId>) -> Self—
Position against a different mounted element instead of the trigger, Base UI's `anchor`.
pub fn anchor_element(mut self, anchor: impl Into<ElementId>) -> Selfソースを見るanchor_pointpub fn anchor_point(mut self, anchor: Point) -> Self—
Position against a logical window point instead of the trigger, Base UI's virtual `anchor`.
pub fn anchor_point(mut self, anchor: Point) -> Selfソースを見るanchor_triggerpub const fn anchor_trigger(mut self) -> Self—
Position against the trigger again, undoing an anchor override.
pub const fn anchor_trigger(mut self) -> Selfソースを見るmodalpub const fn modal(mut self, modal: bool) -> Self—
Make the open popover modal, Base UI's `modal` prop. A modal popover contains Tab focus inside the popup and expects a mounted [`Self::backdrop_with`] to absorb outside pointer input. QuickGUI adds no dimming: the backdrop stays an invisible caller-owned element until the application paints it.
pub const fn modal(mut self, modal: bool) -> Selfソースを見るis_modalpub const fn is_modal(self) -> bool—
arrow_sizepub fn arrow_size(mut self, size: f32) -> Self—
Declare the edge length of a framework-positioned arrow. [`Self::arrow_with`] centers an arrow of this size on the anchor. Leaving it at zero pins the arrow to the resolved edge without a cross-axis offset, which is what an application that centers the arrow with its own layout wants.
pub fn arrow_size(mut self, size: f32) -> Selfソースを見るarrow_paddingpub fn arrow_padding(mut self, padding: f32) -> Self—
Keep a framework-positioned arrow this far from the popup's corners, Base UI's `arrowPadding`.
pub fn arrow_padding(mut self, padding: f32) -> Selfソースを見るtrack_placementpub fn track_placement(mut self, placement: &AnchorPlacementHandle) -> Self—
Adopt the placement QuickGUI resolved for this popover on the previous painted frame. Store an [`AnchorPlacementHandle`] on the view next to `open`, mount the positioner with [`Self::tracked_positioner_with`] or [`Self::tracked_surface_with`], and pass the handle here while declaring the next frame. [`Self::arrow_with`], [`Self::resolved_side`], [`Self::resolved_align`], and [`Self::state`] then follow the placement the popover really used instead of the declared preference. QuickGUI requests exactly one correcting frame when the resolved placement changes, so a flipped popover settles immediately and an unflipped one adds no redraw source.
pub fn track_placement(mut self, placement: &AnchorPlacementHandle) -> Selfソースを見るresolved_placementpub const fn resolved_placement(mut self, resolved: Option<ResolvedAnchorPlacement>) -> Self—
Adopt an already-read placement report. Use this when the application keeps the snapshot itself rather than the handle.
pub const fn resolved_placement(mut self, resolved: Option<ResolvedAnchorPlacement>) -> Selfソースを見るresolved_sidepub fn resolved_side(self) -> AnchorSide—
The side the popover actually opened on, or the declared preference before the first frame.
pub fn resolved_side(self) -> AnchorSideソースを見るresolved_alignpub fn resolved_align(self) -> AnchorAlign—
The cross-axis alignment the popover actually used, or the declared preference.
pub fn resolved_align(self) -> AnchorAlignソースを見るresolved_anchor_placementpub fn resolved_anchor_placement(self) -> AnchorPlacement—
The full placement the popover actually used, or the declared preference.
pub fn resolved_anchor_placement(self) -> AnchorPlacementソースを見るstatepub fn state(self) -> PopoverPartState—
A copyable snapshot of what Base UI exposes as `data-*` attributes and CSS variables. The application styles from this: it picks a transform origin from [`PopoverPartState::side`], hides a popup whose anchor scrolled away using [`PopoverPartState::anchor_hidden`], matches the trigger width with [`PopoverPartState::anchor_width`], and caps a scrolling viewport with [`PopoverPartState::available_height`]. Every measured field stays zero until the popover has been painted once with a bound placement handle.
pub fn state(self) -> PopoverPartStateソースを見るanchor_gappub fn anchor_gap(mut self, gap: f32) -> Self—
Set the structural distance between the trigger and positioner.
pub fn anchor_gap(mut self, gap: f32) -> Selfソースを見るviewport_marginpub fn viewport_margin(mut self, margin: f32) -> Self—
Set the structural collision margin inside the current window viewport.
pub fn viewport_margin(mut self, margin: f32) -> Selfソースを見るinitial_focuspub fn initial_focus(mut self, focus: impl Into<ElementId>) -> Self—
Prefer a mounted popover descendant instead of the popover root when opening.
pub fn initial_focus(mut self, focus: impl Into<ElementId>) -> Selfソースを見るdismiss_on_escapepub const fn dismiss_on_escape(mut self, dismiss: bool) -> Self—
Configures dismiss on escape for this part.
pub const fn dismiss_on_escape(mut self, dismiss: bool) -> Selfソースを見るdismiss_on_pointer_outsidepub const fn dismiss_on_pointer_outside(mut self, dismiss: bool) -> Self—
Configures dismiss on pointer outside for this part.
pub const fn dismiss_on_pointer_outside(mut self, dismiss: bool) -> Selfソースを見るis_openpub const fn is_open(self) -> bool—
trigger_idpub const fn trigger_id(self) -> ElementId—
surface_idpub const fn surface_id(self) -> ElementId—
Stable popover identity retained under the existing `surface` name.
pub const fn surface_id(self) -> ElementIdソースを見るpopover_idpub const fn popover_id(self) -> ElementId—
positioner_idpub fn positioner_id(self) -> ElementId—
backdrop_idpub fn backdrop_id(self) -> ElementId—
title_idpub fn title_id(self) -> ElementId—
description_idpub fn description_id(self) -> ElementId—
close_idpub fn close_id(self) -> ElementId—
arrow_idpub fn arrow_id(self) -> ElementId—
viewport_idpub fn viewport_id(self) -> ElementId—
Stable identity of the scrolling viewport mounted inside the popup.
pub fn viewport_id(self) -> ElementIdソースを見るtrigger_focuspub fn trigger_focus(self) -> FocusHandle—
surface_focuspub fn surface_focus(self) -> FocusHandle—
popover_focuspub fn popover_focus(self) -> FocusHandle—
focus_surfacepub fn focus_surface(self, cx: &mut EventContext)—
Move focus to the declared initial target, or the popover root, in the same controlled update.
pub fn focus_surface(self, cx: &mut EventContext)ソースを見るPopover::root
ソースを見るpub fn root(self) -> ElementGroup the trigger and floating content in an ordinary, unstyled view.
Popover::root_with
ソースを見るpub fn root_with(self, root: Element) -> ElementUse an existing view as the popover's composition root.
Popover::trigger_with
ソースを見るpub fn trigger_with(self, trigger: Element) -> ElementDecorate an application-owned trigger without adding appearance.
Popover::trigger
ソースを見るpub fn trigger(self) -> ElementCreate an unstyled semantic trigger root.
Popover::positioner_with
ソースを見るpub fn positioner_with(self, positioner: Element) -> ElementDecorate the caller-owned portal/positioner without adding popover appearance. QuickGUI's retained overlay node is itself the portal, so this part combines the Base UI-style Portal and Positioner boundary without introducing a full-window wrapper that would block unrelated pointer input.
Popover::positioner
ソースを見るpub fn positioner(self) -> ElementCreate the unstyled positioner part. Use [`Self::positioner_with`] to supply an existing element.
Popover::tracked_positioner_with
ソースを見るpub fn tracked_positioner_with( self, positioner: Element, placement: &AnchorPlacementHandle, ) -> ElementDecorate the positioner and publish the placement it resolves to. This is [`Self::positioner_with`] plus [`crate::Element::report_anchor_placement`]: the handle receives the side, alignment, anchor rectangle, and remaining room the popover actually used, and [`Self::track_placement`] feeds it back into the descriptor on the next frame.
Popover::tracked_positioner
ソースを見るpub fn tracked_positioner(self, placement: &AnchorPlacementHandle) -> ElementCreate the unstyled tracked positioner part. Use [`Self::tracked_positioner_with`] to supply an existing element.
Popover::portal_with
ソースを見るpub fn portal_with(self, portal: Element) -> ElementBase UI's Portal name for the combined portal/positioner part. QuickGUI's retained overlay node is itself the portal, so Portal and Positioner are one element; both names decorate it identically.
Popover::portal
ソースを見るpub fn portal(self) -> ElementCreate the unstyled portal part. Use [`Self::portal_with`] to supply an existing element.
Popover::popup_with
ソースを見るpub fn popup_with(self, popover: Element) -> ElementDecorate an application-owned popover without adding layout or appearance. The popover emits [`crate::Event::Dismiss`] under [`Self::surface_id`] for every enabled dismissal path. Mounted title/description parts are related without copying their text.
Popover::popup
ソースを見るpub fn popup(self) -> ElementCreate the unstyled popup part. Use [`Self::popup_with`] to supply an existing element.
Popover::surface_with
ソースを見るpub fn surface_with(self, surface: Element) -> ElementDecorate one caller-owned element as both positioner and popover. This compact form has the same unstyled contract as composing [`Self::positioner_with`] around [`Self::popup_with`]. Use separate parts when the application needs to animate or size the positioner independently from popover presentation.
Popover::tracked_surface_with
ソースを見るpub fn tracked_surface_with( self, surface: Element, placement: &AnchorPlacementHandle, ) -> ElementDecorate the merged surface and publish the placement it resolves to.
Popover::tracked_surface
ソースを見るpub fn tracked_surface(self, placement: &AnchorPlacementHandle) -> ElementCreate the unstyled tracked surface part. Use [`Self::tracked_surface_with`] to supply an existing element.
Popover::surface
ソースを見るpub fn surface(self) -> ElementCreate an unstyled merged positioner/popover root.
Popover::arrow_with
ソースを見るpub fn arrow_with(self, arrow: Element) -> ElementPosition a caller-owned arrow on the edge the popover actually opened against. The arrow is absolutely positioned inside the popup, pinned to the edge that faces the anchor and centered on the anchor along the cross axis. When [`Self::track_placement`] has supplied a placement report the offsets follow the real placement, including a flip — never the declared preference. Before the first painted frame, or without a bound handle, the arrow follows the declared side and stays centered on the popup, and QuickGUI's one correcting frame moves it as soon as the real placement is known. The application owns the arrow's size, shape, rotation, and color. Declare [`Self::arrow_size`] when QuickGUI should center an arrow of a known edge length, and [`Self::arrow_padding`] to keep it clear of the popup's corners. The arrow is hidden from assistive technology: it is decoration attached to a surface that already carries the relationship.
Popover::arrow
ソースを見るpub fn arrow(self) -> ElementCreate the unstyled arrow part. Use [`Self::arrow_with`] to supply an existing element.
Popover::viewport_with
ソースを見るpub fn viewport_with(self, viewport: Element) -> ElementDecorate a caller-owned scrolling viewport mounted inside the popup. Base UI's Viewport clips content that changes size between triggers so the popup can animate between them. QuickGUI supplies the stable identity and the scroll container; height, padding, and motion stay application-owned — cap it with [`PopoverPartState::available_height`] to keep a long popup inside the window.
Popover::viewport
ソースを見るpub fn viewport(self) -> ElementCreate the unstyled viewport part. Use [`Self::viewport_with`] to supply an existing element.
Popover::backdrop_with
ソースを見るpub fn backdrop_with(self, backdrop: Element) -> ElementDecorate an optional caller-painted viewport backdrop.
Popover::backdrop
ソースを見るpub fn backdrop(self) -> ElementCreate the unstyled backdrop part. Use [`Self::backdrop_with`] to supply an existing element.
Popover::title_with
ソースを見るpub fn title_with(self, title: Element) -> ElementAssign the stable mounted label target used by the popover.
Popover::title
ソースを見るpub fn title(self) -> ElementCreate the unstyled title part. Use [`Self::title_with`] to supply an existing element.
Popover::description_with
ソースを見るpub fn description_with(self, description: Element) -> ElementAssign the stable mounted description target used by the popover.
Popover::description
ソースを見るpub fn description(self) -> ElementCreate the unstyled description part. Use [`Self::description_with`] to supply an existing element.
Popover::close_with
ソースを見るpub fn close_with(self, label: impl Into<Arc<str>>, close: Element) -> ElementDecorate a caller-owned close control with button behavior and no visual defaults.
Popover::close
ソースを見るpub fn close(self, label: impl Into<Arc<str>>) -> ElementCreate the unstyled close part. Use [`Self::close_with`] to supply an existing element.
