Aspect Ratio
Keeps an image or video at a fixed ratio as it resizes.
When to use
- An image or a video that must keep its shape as the layout resizes.
- A placeholder that reserves the space before media loads, so the page doesn't jump.
When not to use
- A fixed-size thumbnail: set a
size-*class on the image. - A person's photo: use Avatar.
Install
npx shadcn@latest add @clinia/aspect-ratio
Clinia rules
- Pass
ratioas width over height:16 / 9,4 / 3,1. - Add
overflow-hiddenand a radius to the box, andobject-coverto the image, so it crops instead of stretching.
Do and don't


Accessibility
Your responsibility
- Give every image
alttext that says what it shows, oralt=""when it's decorative. - The box only sets the shape. A video still needs captions and controls.
How to test
- Resize the window: the box keeps its ratio and the image crops, never stretches.
- Zoom to 200%: nothing overflows the page.
API
| Prop | Values | Default | Description |
|---|---|---|---|
| ratio | number | – | Width divided by height, such as |
All other props come from the native div element.