Components/Popover

Popover

Semantic popover built directly on BaseAnchor.

VerifiedSince 0.3.4

Usage

Popover

Loading demo...

Best Practices

  • Keep popover content short: explanations, compact filters, and one or two lightweight actions.
  • Use toggleOnReferenceClick=false when the reference contains an input or custom focus behavior, as TxSearchSelect does.
  • Leave keepAliveContent=true for small forms or stateful filters; set it to false only for static copy.
  • Use maxHeight or internal scrolling for option panels instead of allowing a popover to cover the viewport.
  • There is no arrow by default. Turn on showArrow only when several triggers sit close together and the panel has to show which one it belongs to; with offset unset, the gap grows to fit the arrow.

API Reference

TxPopover Props

PropTypeDefaultDescription
modelValueboolean-Open state (v-model)
disabledbooleanfalseDisable interaction
eagerbooleanfalseMounts anchor content eagerly through TxBaseAnchor.
placementPopoverPlacement'bottom-start'Floating placement
offsetnumberautoGap: 6 without an arrow (matching DropdownMenu and Select), max(8, arrowSize / 2 + 2) with one
widthnumber0Panel width (0 follows reference width)
minWidthnumber0Minimum panel width
maxWidthnumber360Maximum panel width
maxHeightnumber420Maximum panel height before internal overflow handling.
unlimitedHeightbooleanfalseDisables the max-height cap for panels that manage their own scrolling.
referenceFullWidthbooleanfalseStretch reference container to full width
referenceClassBaseAnchorClassValue-Additional class value forwarded to the BaseAnchor reference wrapper.
showArrowbooleanfalseShow arrow. The anchor family draws no arrow by default; opt in per instance
arrowSizenumber12Arrow size
trigger'click' | 'hover''click'Trigger mode
openDelaynumberFrom the menu preset (120)Hover open delay (ms). Left unset, the shared delay service supplies it.
closeDelaynumberFrom the menu preset (100)Hover close delay (ms). Left unset, the shared delay service supplies it.
animationBaseAnchorAnimationOptions{ type: 'expand' }Anchor animation config forwarded to BaseAnchor; spring expand by default — classic types (transfer etc.) get duration: 180 / ease: 'power2.out' injected.
keepAliveContentbooleantrueKeep floating content mounted between open/close
toggleOnReferenceClickbooleantrigger === 'click'Toggle by clicking reference
panelVariant'solid' | 'dashed' | 'plain''solid'Card border variant
panelBackground'pure' | 'mask' | 'blur' | 'glass' | 'refraction''refraction'Card background style
panelShadow'none' | 'soft' | 'medium''soft'Card shadow style
panelRadiusnumber18Card radius
panelPaddingnumber10Card padding
panelCardBaseAnchorPanelCardProps-Advanced override object forwarded to the BaseAnchor panel card.
closeOnClickOutsidebooleantrueClose on outside click (click trigger only)
closeOnEscbooleantrueClose on ESC

Events

EventParamsDescription
open-Emitted when uncontrolled or internal state opens.
close-Emitted when uncontrolled or internal state closes.
update:modelValuebooleanEmitted whenever Popover requests a controlled or uncontrolled open state change.

Slots

SlotPropsDescription
reference-Trigger/reference content rendered inside the anchor reference wrapper.
default{ side: string }Popover panel content. side is the resolved floating side from TxBaseAnchor.

Trigger And Panel Behavior

Popover (trigger and panel)

Loading demo...

Dashboard Navigation Composition

Admin pages should not put every setting into one large form. Use TxTabs for first-level sections, TxDropdownMenu for lightweight actions in the current section, TxPopover for short explanations, and TxDrawer for dense configuration.

Dashboard navigation shell

A screenshot-verified Tabs / DropdownMenu / Popover / Drawer composition for Dashboard settings pages.

Loading demo...

Overview

  • With trigger="click", outside-click and Escape closing are available; with trigger="hover", open/close delays apply, and the trip to the panel is covered by the hover bridge and the safe triangle (rules in Tooltip's Overview): crossing the offset gap, resting on the panel's padding, or passing another hover trigger diagonally neither closes the panel nor hands it away.
  • Use keepAliveContent for filters, short forms, and stateful explanation panels; disable it for pure display copy when state does not matter.
  • Popover should stay lightweight; upgrade to Drawer for one-screen-plus content, footer actions, or multi-field configuration.

Technologies

  • Reviewed against packages/tuffex/packages/components/src/popover/src/types.ts, TxPopover.vue, and popover.test.ts.
  • With offset unset, the gap is 6px without an arrow and derived from arrowSize with one; examples should not imply a fixed default gap.
  • Rejected design: keeping the old 2px no-arrow gap once the arrow went off by default. Measured, the panel's top edge sat 1.8px from the trigger, over the trigger's 3px focus outline, so it uses the menu family's 6px instead.
  • closeOnClickOutside is click-trigger only because hover mode owns close timing through pointer/focus leave delays.
  • Component source: packages/tuffex/packages/components/src/popover/src/TxPopover.vue.
  • Types: packages/tuffex/packages/components/src/popover/src/types.ts.
  • Verified coverage: packages/tuffex/packages/components/src/popover/__tests__/popover.test.ts verifies default BaseAnchor prop forwarding (no arrow by default), offset derivation (6 without an arrow, 8 with the default arrow, a custom arrow size, an explicit value), hover trigger timing, the hover zone spanning the whole floating layer (leaving the content for the card padding does not close), disabled-close behavior, full-width reference classes, and content side slot props.
查看源码
packages/tuffex/packages/components/src/popover/index.ts