How to build an accessible AspectRatio in React

Purely presentational wrapper with no role; the inner media element carries its own semantics and alt text

When to use a AspectRatio

When not to use it

Accessibility

Role none, verified at WCAG 2.2-AA.

Common mistakes

Avoid: Wrapping text content that must expand to fit its lines

Prefer: Reserve AspectRatio for media; let prose flow at its intrinsic height

A fixed ratio clips or distorts content that needs variable height

Example

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

See the full AspectRatio reference →