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.
aspect-[4/3]Classic photos and thumbnails
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.
Import
Section titled “Import”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.
16:9 landscape cover
4:3 editorial thumbnail
Semantic content
Section titled “Semantic content”Use as when the ratio box itself has semantic meaning. Native props and the ref follow the selected element.
Choosing a ratio
Section titled “Choosing a ratio”Pass a positive number using width divided by height:
| Ratio | Value | Typical use |
|---|---|---|
1:1 | 1 | Avatars, square tiles, and icons |
4:3 | 4 / 3 | Classic photos and thumbnails |
3:2 | 3 / 2 | Landscape photography |
16:9 | 16 / 9 | Video and product previews |
21:9 | 21 / 9 | Cinematic banners and hero media |
4:5 | 4 / 5 | Portrait cards and social media |
2:3 | 2 / 3 | Posters and editorial covers |
9:16 | 9 / 16 | Stories 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
| Prop | Type | Default | Description |
|---|---|---|---|
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-*.
Accessibility
Section titled “Accessibility”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.