API Reference

Canonical API reference and composable index for VFloat.

VFloat provides composable primitives for building anchored floating interfaces in Vue 3. Each composable handles one focused responsibility: lifecycle and refs, positioning calculations, interaction listeners, accessibility semantics, or keyboard navigation.

Use the Guides to learn end-to-end workflows and architectural principles. Use these API reference pages when you need exact signatures, options, return shapes, and integration contracts.

Choose Primitives by Goal

Pick the combination of composables and middleware that matches your interface pattern:

Interface PatternPrimary ComposablesSuggested MiddlewareGuide
TooltipuseFloatingNode, useHover, usePositionoffset, flip, shift, arrowFirst Tooltip
Popover / DropdownuseFloatingNode, useClick, useOutsideClick, useEscapeKey, usePositionoffset, flip, shiftFirst Menu
Dialog / ModaluseFloatingNode, useFocusTrap, useEscapeKey, useOutsideClick, useRoleNone (CSS centered)Focus Models
ContextMenu / CursoruseFloatingNode, useClientPoint, useOutsideClick, useEscapeKey, usePositionflip, shiftVirtual Anchors
Menu with Roving FocususeFloatingNode, useRovingFocus, useClick, useOutsideClick, useEscapeKeyoffset, flip, shiftKeyboard Navigation
Nested Menu TreeuseFloatingNode, useRovingFocus, useOutsideClick, useEscapeKeyoffset, flipHierarchy
Combobox / AutocompleteuseAriaActivedescendant, useTypeahead, usePositionoffset, flip, sizeKeyboard Navigation

Core

Core primitives manage node identity, shared element references, open/close lifecycle, and composite tree hierarchies.

ComposableDescription
useFloatingNodeCreates a composite floating node managing element refs, open state, and parent-child hierarchy.
TypesCanonical types, navigation protocols, and data structures exported by VFloat.

Positioning

Positioning composables compute screen coordinates, run the middleware pipeline, listen to viewport changes, and generate style bindings.

ComposableDescription
usePositionComputes reactive coordinates and automatically applies inline positioning styles to the floating element.
useArrowRegisters an arrow element with the positioning pipeline and automatically applies computed arrow styles.
useClientPointPositions a floating element relative to pointer coordinates using a virtual anchor.

Interactions

Interaction composables attach DOM event listeners to the anchor or document to open, close, and manage focus for floating surfaces.

ComposableDescription
useClickToggles open state from click, tap, or keyboard activation on the anchor.
useHoverOpens and closes floating content on pointer hover with delay and safe polygon tracking.
useFocusOpens and closes floating content when the anchor gains or loses keyboard focus.
useFocusTrapManages modal focus containment, boundary sentinels, background isolation, and return focus.
useOutsideClickCloses open floating surfaces when pointer interactions occur outside the floating family.
useEscapeKeyCloses open floating surfaces on Escape key presses with leaf-first hierarchy and IME coordination.
useRoleSynchronizes ARIA roles, popup states, and accessibility relationships on anchor and panel.

Keyboard Navigation

Primitives for managing keyboard navigation patterns in dropdowns, menus, and comboboxes.

ComposableDescription
useRovingFocusMoves physical DOM focus between elements in composite widgets using roving tabindex.
useAriaActivedescendantVirtual focus keeping DOM focus on an input while highlighting options via aria-activedescendant.
useTypeaheadCaptures rapid typing sequences to jump directly to matching items in a list.

Middleware

Positioning middleware runs sequentially inside usePosition to modify placement, prevent collisions, add spacing, or measure boundary constraints.

Configure them declaratively inside usePosition(node, { middlewares: { ... } }) or pass middleware instances directly.

MiddlewarePipeline PhaseDeclarative KeyDescription
offset1. Distanceoffset: 8Adds distance along the main and cross axes between anchor and panel.
flip2. Collisionflip: trueFlips to the opposite or fallback placement when space is constrained.
shift3. Boundaryshift: trueNudges the floating element along its axis to remain inside the viewport.
autoPlacement4. PlacementautoPlacement: trueSelects the placement with the greatest available space (alternative to flip).
size5. Sizingsize: { apply }Measures available space to resize or constrain panel dimensions.
inline6. Geometryinline: truePositions relative to individual client rects for multi-line inline triggers.
arrow7. Decoratorarrow: truePositions an arrow element aligned with the anchor.
hide8. Visibilityhide: trueDetects when the anchor is clipped or when the panel escapes its boundary.

Conventions Across APIs

  • Reactivity: Options accept plain values, Vue refs, or getter functions (MaybeRefOrGetter<T>). Changes automatically re-evaluate active composables.
  • Node Coupling: Every composable in a floating surface accepts the same FloatingNode created by useFloatingNode.
  • Style Binding: By default (applyStyles: true), usePosition and useArrow automatically synchronize positioning and arrow styles directly to node.refs.floatingEl and node.refs.arrowEl. Alternatively, set applyStyles: false and bind :style="styles" or :style="arrowStyles" manually in templates.

Released under the MIT License. Copyright © 2026