Overview
Aspect Ratio maintains a consistent width-to-height ratio for its child, regardless of the container width. It uses the CSS padding-bottom trick under the hood — no JavaScript resizing required.
Installation
Usage
Variants
16:9 — Video / Widescreen
4:3 — Classic / Presentation
1:1 — Square / Avatar / Product
Responsive Image Grid
API Reference
The width-to-height ratio. Pass as a fraction: 16/9, 4/3, 1/1, 9/16.
Additional class names applied to the outer container.
Common Ratios
Accessibility
AspectRatio is a purely layout utility — no ARIA roles needed
Ensure child images have descriptive alt text
For videos, ensure controls are visible or provide accessible custom controls
The container does not affect tab order or screen reader behavior
Do’s & Don’ts
Do
Always set a width on the parent container — AspectRatio fills 100% of its parent
Use object-cover on child images to fill without distortion
Apply overflow-hidden on the container when using border-radius
Use for images, videos, iframes, and map embeds
Don't
Don’t use AspectRatio for text content — height will clip text on small screens
Don’t nest AspectRatios — the inner one overrides the outer
Don’t forget to set the parent width — without it, the component has zero size
Don’t use object-contain with overflow-hidden — it creates letterboxing gaps