Skip to content
Alea0.1

Layout

AspectRatio

Keeps media at a width-to-height ratio as it resizes.

Ant Design: -

import { AspectRatio } from '@alea/ui';

Examples

Ratios

16:9, 4:3 and square boxes that keep their shape as they resize.

16:9
4:3
1:1

Props

AspectRatio props

Keeps its content at a width-to-height ratio: videos, maps, images (Radix AspectRatio).

PropTypeDefaultDescription
classNamestring-Extra class names for the root element.
rationumber16width / height, e.g. 16 / 9. Default 16 / 9.
styleCSSProperties-Inline styles for the root element.

Do and don't

Do

  • Use it for embeds (video, maps) so the page doesn't jump while they load.

Don't

  • Don't crop images that carry information.
Tested with axe, keyboard and screen reader roles