PRIMITIVES
AspectRatio
Locks a child element to a specific width-to-height ratio. Composes the Radix @radix-ui/react-aspect-ratio primitive — the wrapper guarantees no layout shift while the image / video / iframe loads.
Import
16:9 image
16 : 9
Square (1:1)
1 : 1
Props
AspectRatio props
| Prop | Type | Default | Description |
|---|---|---|---|
| ratio | number | 1 | Width-to-height ratio (e.g. 16 / 9, 4 / 3, 1 for a square). The child element is forced to fill the box. |
| children | ReactNode | — | Pass a single element that should fill the aspect-ratio container. |
| className | string | — | Tailwind classes are merged on top of the wrapper. |
Common ratios
16 / 9— widescreen video, hero banners4 / 3— legacy media, photo galleries1— square thumbnails, avatars3 / 4— portrait photo21 / 9— ultra-wide hero