usePosition
Commons
stable
Derives CSS positioning classes and inline style declarations from IPositionProps. Emits a BEM modifier class for the position variant (absolute, fixed, sticky, relative, static) and inline top/bottom/left/right properties for any offset props that are set.
API
Signature
Full TypeScript signature sourced from the composable file.
Consumed interfaces
IPositionProps
API
Parameters
Input parameters accepted by this composable.
- propsrequiredIPositionProps
- Props containing `position` (CSS position keyword), `top`, `bottom`, `left`, `right` (CSS length values or token references).
- namestringgetCurrentInstanceName()
- Component name prefix used to build the BEM modifier class, e.g. "origam-btn" → "origam-btn--fixed".
API
Return values
Properties and methods exposed by the composable return object.
- positionClasses
- BEM modifier class string when position is set (e.g. "origam-card--sticky"), undefined otherwise.
- positionStyles
- Array of inline CSS declarations for top / bottom / left / right. Only includes sides that have a non-falsy prop value.
Usage
Examples
Ready-to-paste usage snippets.
Sticky banner
Floating action button
Inside a custom component