Components/Popover

Popover

A lightweight panel anchored to its trigger.

VerifiedSince 0.3.4

Usage

Basic

Loading demo...

Trigger and Panel

trigger picks click or hover; panelBackground and the other panel* props style the panel.

Loading demo...

Dashboard Navigation

Tabs hold the top-level sections; light actions go in TxDropdownMenu, short notes in TxPopover, and dense settings in TxDrawer.

Loading demo...

Best Practices

  • Hold short notes, compact filters, and one or two light actions; move anything past one screen or with many fields to a Drawer.
  • Set toggleOnReferenceClick=false when the reference contains an input or manages its own focus, as TxSearchSelect does.
  • Keep keepAliveContent on for stateful filters and small forms; static copy can turn it off.
  • Bound option panels with maxHeight or inner scrolling rather than letting a popover cover the viewport.
  • Turn on showArrow only when triggers sit close together and the panel must show which one it belongs to.

API Reference

Props

PropTypeDefaultDescription
modelValueboolean-Whether the panel is open (v-model); omit it for uncontrolled use.
disabledbooleanfalseBlocks opening and closes an open panel.
eagerbooleanfalseMounts the content before the first open.
placementPopoverPlacement'bottom-start'Preferred side.
offsetnumberautoGap to the reference: 6 without an arrow, max(8, arrowSize / 2 + 2) with one.
widthnumber0Panel width; 0 matches the reference width.
minWidthnumber0Minimum width.
maxWidthnumber360Maximum width.
maxHeightnumber420Maximum height; content beyond it scrolls inside the panel.
unlimitedHeightbooleanfalseRemoves the height cap, for panels that scroll themselves.
referenceFullWidthbooleanfalseStretches the reference container to full width.
referenceClassBaseAnchorClassValue-Extra class for the reference wrapper.
showArrowbooleanfalseShows an arrow.
arrowSizenumber12Arrow size in px.
trigger'click' | 'hover' | 'manual''click'How it opens; manual binds no reference interaction, so modelValue alone decides.
openDelaynumberFrom the menu preset (120)Hover open delay in ms; the shared delay service supplies it when unset.
closeDelaynumberFrom the menu preset (100)Hover close delay in ms; the shared delay service supplies it when unset.
animationBaseAnchorAnimationOptions{ type: 'expand' }Animation config forwarded to BaseAnchor; each type uses its own default timing.
virtualReferenceBaseAnchorVirtualReference-Positions against an arbitrary rect, such as the pointer or a selection, instead of the reference.
matchReferenceWidthbooleanwidth <= 0With width at 0, matches the reference width; false sizes the panel to its content.
keepAliveContentbooleantrueKeeps content and its state after close.
toggleOnReferenceClickbooleantrigger === 'click'Toggles on reference click.
panelVariant'solid' | 'dashed' | 'plain''solid'Panel border style.
panelBackground'pure' | 'mask' | 'blur' | 'glass' | 'refraction''refraction'Panel background.
panelShadow'none' | 'soft' | 'medium''soft'Panel shadow.
panelRadiusnumber18Panel corner radius in px.
panelPaddingnumber10Panel padding in px.
panelCardBaseAnchorPanelCardProps-Advanced overrides forwarded to the panel card.
closeOnClickOutsidebooleantrueCloses on an outside click; ignored with hover.
closeOnEscbooleantrueCloses on Escape.

Events

EventParamsDescription
open-Fires when the popover opens itself.
close-Fires when the popover closes itself.
update:modelValuebooleanFires when the popover requests an open-state change, controlled or not.

Slots

SlotPropsDescription
reference-Trigger content, rendered inside the reference wrapper.
default{ side: string }Panel content; side is the final side.

Exposed Methods

NameTypeDescription
updatePosition() => voidRecomputes the position; call it after the virtualReference rect changes.

Overview

  • With modelValue it is controlled; otherwise it keeps its own open state.
  • With trigger="click", a reference click toggles it and an outside click or Escape closes it; with hover, delays drive it and outside clicks are ignored.
  • On the way to the panel, the hover bridge and safe triangle hold it open: crossing the offset gap, resting on the panel padding, or passing another hover trigger diagonally neither closes it nor hands it away.

Technologies

  • Built on TxTooltip (layer="menu"); the shared anchor-delay service schedules its delays and closes other panels on the same layer.
  • Source: packages/tuffex/packages/components/src/popover/.
查看源码
packages/tuffex/packages/components/src/popover/index.ts