Aspect Ratio
stableConstrains content to a desired width / height ratio.
Basic usage
16:9
Examples
Portrait and square
Use different ratios for portrait (4/5) and square (1/1) crops.
4:5
1:1
Media cards
AspectRatio keeps image, video and preview tiles stable across responsive widths.
4:3 preview area
Features
- Any ratio.
- Works with images or any node.
Installation
bash
pnpm dlx structyl add aspect-ratioAPI Reference
AspectRatio
Constrains content to a width/height ratio.
| Prop | Type | Default |
|---|---|---|
| ratio | numberThe desired ratio, e.g. 16 / 9. | 1 |
| className | stringAdditional Tailwind classes, merged with the component defaults. | — |