useDensity
Commons
stable
Emits the density modifier class (`compact`, `default`, `comfortable`) onto the root element. Component SCSS rules then pick up the matching density token to adjust spacing, padding and line-height without JS involvement.
API
Signature
Full TypeScript signature sourced from the composable file.
useDensity only emits a class — there is no densityStyles. All spacing adjustments live in the component SCSS via the `{name}--density-*` selector tree.
Consumed interfaces
IDensityProps
API
Parameters
Input parameters accepted by this composable.
- propsrequiredIDensityProps | Ref<number | string | undefined>
- Component props extending IDensityProps, or a plain Ref. Reads the `density` value.
- namestringgetCurrentInstanceName()
- Component name prefix for the `{name}--density-{value}` class.
API
Return values
Properties and methods exposed by the composable return object.
- densityClasses
- A single-element array containing the density modifier class (e.g. ["origam-btn--density-compact"]), or an empty array when density is null/undefined.
Usage
Examples
Ready-to-paste usage snippets.
Density variants