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.
Interfaces consommées
ILocationProps
ILocationStrategyProps
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- propsrequisILocationProps
- Component props extending ILocationProps. The location key accepts a TAnchor string ("top", "bottom start", "right center", etc.).
- oppositebooleanfalse
- 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
Opposite anchor (tooltip above host)