AspectRatio
AspectRatio is a Box that enforces a fixed width-to-height ratio on its child. Reach for it when the surface needs to keep its shape across breakpoints — image cards, video embeds, social previews.
Loading playground…
What it is
A <Box> with the CSS aspect-ratio property set. The child element fills the container; the
container's height comes from its width and the supplied ratio.
Install
AspectRatio is exported from usemotif. No separate install.
API
AspectRatio
stablefunction AspectRatio(props: AspectRatioProps): JSX.Element
rationumber= 1
Width divided by height. Pass `16/9`, `4/3`, `1`, or any positive number.
…BoxPropsOmit<BoxProps, "aspectRatio">
Every Box prop except `aspectRatio`. The component sets `aspectRatio` via `style`; pass the ratio through `ratio` instead.
Examples
Sixteen-by-nine cover image:
Square avatar slot:
Video embed: