Layout
AspectRatio
Box locked to an aspect ratio; children stretch to fill.
import { AspectRatio } from "datui";Examples
Ratios
16 / 9
Square, children not stretched
Accessibility
- Layout only; semantics come from the children.
API
AspectRatio
Box locked to an aspect ratio at fluid width.
| Prop | Type | Default | Description |
|---|---|---|---|
| ratio (required) | string | number | — | Width / height, as a number (`16 / 9`) or any CSS `aspect-ratio` value (`"4 / 3"`, `var(--x)`). |
| as | ElementType<any, keyof IntrinsicElements> | div | |
| className | string | — | |
| mode | "none" | "stretch" | stretch | `stretch` makes every child fill the box. |