Popper

4 parts

The context provider for a popper. It coordinates positioning between PopperAnchor (the reference element), PopperContent (the floating element placed against it), and PopperArrow, sharing the registered anchor via context. It renders only its slot and adds no DOM of its own, so wrap the anchor and content in it to build tooltips, popovers, dropdown menus, and other floating UI.

Anatomy

Import the parts and compose them. Each part forwards attributes to its underlying element.

vue
import {
  PopperRoot,
  PopperAnchor,
  PopperContent,
  PopperArrow,
} from '@robonen/primitives/overlays/popper';

<PopperRoot>
  <PopperAnchor />
  <PopperContent />
  <PopperArrow />
</PopperRoot>

API Reference

PopperRoot

Root

The context provider for a popper. It coordinates positioning between `PopperAnchor` (the reference element), `PopperContent` (the floating element placed against it), and `PopperArrow`, sharing the registered anchor via context. It renders only its slot and adds no DOM of its own, so wrap the anchor and content in it to build tooltips, popovers, dropdown menus, and other floating UI.

No props or events — renders its element and forwards attributes.

PopperAnchor

Anchor

Marks the element that `PopperContent` positions itself against. Renders its child and registers it with the `PopperRoot` as the positioning reference; pass `reference` to anchor to a virtual or external element instead of the rendered DOM node. Optional — when omitted, the content falls back to its own `reference` prop or the nearest registered anchor.

PropTypeDescription
reference?ReferenceElementCustom reference element for positioning. If not provided, uses the rendered element.

PopperContent

Content

The floating element positioned against the anchor. This is the workhorse of the Popper building block: it runs Floating UI (offset, flip, shift, size, arrow, hide) to place itself on the chosen side/alignment, keeps the position updated on scroll/resize/layout shift, avoids collisions with the viewport or a custom boundary, and exposes `--popper-*` CSS variables plus `data-side` / `data-align` attributes for styling and transform-origin. Use the Popper parts to build any anchored overlay — tooltips, popovers, menus, selects — where content must follow a trigger and stay on-screen. Place it inside a `PopperRoot` (so it can read the registered anchor) and emit `placed` once the first position settles.

PropTypeDescription
side?SidePreferred side of the anchor.
sideOffset?numberDistance in pixels from the anchor.
sideFlip?booleanFlip to the opposite side on collision.
align?AlignPreferred alignment against the anchor.
alignOffset?numberOffset in pixels from the alignment edge.
alignFlip?booleanFlip alignment on collision.
avoidCollisions?booleanReposition to prevent boundary overflow.
collisionBoundary?Array<Element | null> | Element | nullCollision boundary element(s).
collisionPadding?number | Partial<Record<Side, number>>Distance from boundary for collision detection.
arrowPadding?numberPadding between arrow and content edges.
hideShiftedArrow?booleanHide arrow when it can't be centered.
sticky?'always' | 'partial'Sticky behavior on the align axis.
hideWhenDetached?booleanHide when anchor is fully occluded.
positionStrategy?'absolute' | 'fixed'CSS position strategy.
updatePositionStrategy?'always' | 'optimized'Position update strategy.
disableUpdateOnLayoutShift?booleanDisable layout-shift-based position update.
prioritizePosition?booleanForce content to stay within the viewport.
reference?ReferenceElementCustom reference element, overrides the anchor.

PopperArrow

Arrow

An optional arrow/pointer rendered inside `PopperContent` that points back at the anchor. It reads the resolved side and arrow offset from the content context to position and rotate itself against the correct edge, and hides automatically when it cannot be centered. By default it renders a real `<svg>` triangle (a `rounded` variant is available); supply your own SVG/element via the default slot, or switch the rendered element with `as`. Must be a child of `PopperContent`.

PropTypeDescription
width?numberArrow width in pixels.
height?numberArrow height in pixels.
rounded?booleanRender the rounded variant of the default arrow path. Ignored when a custom default slot or as="template" is used.