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
Full TypeScript signature sourced from the composable file.
Consumed interfaces
ILocationProps
ILocationStrategyProps
API
Parameters
Input parameters accepted by this composable.
- propsrequiredILocationProps
- 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
Return values
Properties and methods exposed by the composable return object.
- locationStyles
- Computed CSS properties (top, left, right, bottom, transform) that place the element at the requested anchor position. Bind via :style.
Usage
Examples
Ready-to-paste usage snippets.
Position a badge at top-end
Opposite anchor (tooltip above host)