useDimension
Commons
stable
Resolves the six dimension props (width, height, minWidth, maxWidth, minHeight, maxHeight) into inline CSS declarations. Numbers become `px` values, strings pass through (supports CSS lengths, custom properties and aspect-ratio shortcuts).
API
Signature
Full TypeScript signature sourced from the composable file.
Always extend IDimensionProps rather than declaring width/height manually. A hand-rolled height-only prop silently ignores maxHeight, minHeight, etc.
Consumed interfaces
IDimensionProps
API
Parameters
Input parameters accepted by this composable.
- propsrequiredIDimensionProps
- Component props extending IDimensionProps. Reads width, height, minWidth, maxWidth, minHeight, maxHeight.
API
Return values
Properties and methods exposed by the composable return object.
- dimensionStyles
- Inline CSS declarations for all provided dimension props, e.g. ["width: 200px", "max-height: 50vh"].
Usage
Examples
Ready-to-paste usage snippets.
Basic usage
With CSS custom properties