Skip to content
Playground

Aspect Ratio

Reserve a stable ratio for media and embedded content.

AspectRatio reserves predictable space while its width changes. Use it for images, videos, embeds, previews, and other content whose proportions should remain stable.

Switch between common landscape, square, and portrait ratios to see one image reframed. The frame transitions between dimensions while the image remains centered. Turn off Crop to fill to use object-contain and preserve the complete image with letterboxing.

TSX
import { AspectRatio } from "@zentara-co/zenos-ui";

AspectRatio controls the outer geometry. Size the media to fill that box and choose object-cover or object-contain according to whether cropping is acceptable.

Snow-capped Southern Alps reflected in Lake Matheson

16:9 landscape cover

Minimal modern building with strong geometric shadows

4:3 editorial thumbnail

Use as when the ratio box itself has semantic meaning. Native props and the ref follow the selected element.

Turquoise Moraine Lake surrounded by evergreen forest and mountainsTravel journal
Morning at Moraine Lake

Pass a positive number using width divided by height:

RatioValueTypical use
1:11Avatars, square tiles, and icons
4:34 / 3Classic photos and thumbnails
3:23 / 2Landscape photography
16:916 / 9Video and product previews
21:921 / 9Cinematic banners and hero media
4:54 / 5Portrait cards and social media
2:32 / 3Posters and editorial covers
9:169 / 16Stories and vertical video

Choose the ratio from the destination layout rather than the source file. A stable frame prevents surrounding content from shifting while media loads, and one source image can be reframed for several placements.

The component does not crop or resize its children. It only sets aspect-ratio, full width, and overflow clipping. Use object-cover when filling the frame matters more than preserving every edge, or object-contain when the complete image must remain visible. Add decorative surface, border, radius, and motion styles through className.

API

PropTypeDefaultDescription
as ElementType div Rendered semantic element.
ratio number 1 CSS aspect-ratio value, such as 16 / 9.
native props React.HTMLAttributes<HTMLElement> — Forwards native attributes, events, aria-*, data-*, className, style, and ref.

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

AspectRatio does not change child semantics. Images still need meaningful alternative text when informative and an empty alt when decorative. Videos and embeds retain their own caption, title, and keyboard requirements. Avoid placing essential text where media cropping can hide it.