useLocation

Commons
stable

Converts a semantic anchor string (e.g. "top center", "bottom end") into CSS positioning styles for absolutely-placed elements. Used internally by Badge, Chip, and floating content components to position decorators relative to their host. Also exposes useLocationStrategies for the full popup positioning pipeline.

API

Signature

Signature TypeScript complète extraite du fichier du composable.

typescript

Interfaces consommées

ILocationProps
ILocationStrategyProps

API

Paramètres

Paramètres d'entrée acceptés par ce composable.

props
requis
ILocationProps
Component props extending ILocationProps. The location key accepts a TAnchor string ("top", "bottom start", "right center", etc.).
opposite
boolean
false
When true, positions the element on the opposite side (e.g. "top" becomes bottom: calc(100% - Npx)). Used for tooltip anchoring to a host.
offset
(side: string) => number
Optional function returning a pixel offset for a given side string. Allows per-side inset adjustments without altering the anchor semantics.

API

Valeurs de retour

Propriétés et méthodes exposées par l'objet retourné par le composable.

locationStyles
Computed CSS properties (top, left, right, bottom, transform) that place the element at the requested anchor position. Bind via :style.

Usage

Exemples

Extraits de code prêts à coller.

Position a badge at top-end

vue

Opposite anchor (tooltip above host)

vue