Aspect Ratio

A layout component that constrains its content to a given aspect ratio. It automatically fills the available width and adjusts height to maintain the ratio. Images and videos inside will be automatically sized to cover the container.

Source
16 / 9

Props

NameDefaultType
rationumber
The aspect ratio as a single number (e.g. 16/9, 1, 4/3). Required.

Slots

NameAcceptsDescription
defaultanyThe content rendered inside the aspect ratio container

Tokens

CSS variable tokens used for global or per-instance manipulation of certain styling.

TokenDefaultDescription
--vui-aspect-ratio-value0%Aspect ratio as padding-bottom
--vui-aspect-ratio-radiusvar(--border-radius-m)Border radius of the container
--vui-aspect-ratio-fitcoverObject-fit for inner media
--vui-aspect-ratio-positioncenterObject-position for inner media