AspectRatio

Constrains content to a fixed width-to-height ratio

Category: layout · WCAG 2.2-AA · layout, ratio, image, video, responsive

Props

PropTypeDefaultDescription
rationumber16 / 9Width-to-height ratio applied via the CSS aspect-ratio property
childrenReactNodeContent to fill the ratio box (typically an image, video, or iframe)

Design tokens

When to use

When not to use

How to build an accessible AspectRatio in React →

Examples

Image at 16:9

<AspectRatio ratio={16 / 9}>
  <img src="/cover.jpg" alt="Cover" />
</AspectRatio>

Square

<AspectRatio ratio={1}>
  <img src="/avatar.jpg" alt="Avatar" />
</AspectRatio>

Related components

← Back to docs