Aspect Ratio
Keeps content at a set ratio and animates ratio changes.
@paneui/thememotion
Installation
pnpm dlx shadcn@latest add @paneui/aspect-ratioUsage
Composition
Examples
Motion
Ratio changes run as a motion layout animation with a bounce-free spring. With reduced motion the frame jumps straight to its new shape.
AspectRatio
A full-width frame locked to a ratio, with a muted well background. Also accepts every prop of motion.div.
- ratio= 1
- number
- Width divided by height, e.g.
16 / 9. Invalid values fall back to 1. - animated= true
- boolean
- Animate ratio changes. Reduced motion always skips the movement.
- radius= 20
- number
- Corner radius in px.
- contentClassName
- string
- Classes for the absolutely positioned content layer.
| Prop | Type | Default | Description |
|---|---|---|---|
| ratio | number | 1 | Width divided by height, e.g. 16 / 9. Invalid values fall back to 1. |
| animated | boolean | true | Animate ratio changes. Reduced motion always skips the movement. |
| radius | number | 20 | Corner radius in px. |
| contentClassName | string | — | Classes for the absolutely positioned content layer. |
AspectRatioImage
Cover-cropped image for AspectRatio, sized from its real width and height. Must be used inside it. Also accepts every prop of motion.img.
- alt*
- string
- Alternative text.
- width*
- number
- Intrinsic width in px.
- height*
- number
- Intrinsic height in px.
- draggable= false
- boolean
- Native image dragging.
| Prop | Type | Default | Description |
|---|---|---|---|
| alt* | string | — | Alternative text. |
| width* | number | — | Intrinsic width in px. |
| height* | number | — | Intrinsic height in px. |
| draggable | boolean | false | Native image dragging. |