Overview
Aspect Ratio maintains a consistent width-to-height ratio for its child, regardless of the container width. It uses the CSSpadding-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
| Ratio | Value | Use Case |
|---|---|---|
16 / 9 | 1.778 | Video, widescreen images, banners |
4 / 3 | 1.333 | Classic photo, presentations |
3 / 2 | 1.5 | Standard photography |
1 / 1 | 1.0 | Square avatars, product thumbnails |
9 / 16 | 0.5625 | Mobile / portrait video (Reels, TikTok) |
Accessibility
- AspectRatio is a purely layout utility — no ARIA roles needed
- Ensure child images have descriptive
alttext - For videos, ensure
controlsare 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-coveron child images to fill without distortion - Apply
overflow-hiddenon the container when usingborder-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-containwithoverflow-hidden— it creates letterboxing gaps