Velocity X Components

Bento & Layout

Aspect-Ratio Media Box

Reserves a stable aspect ratio for media to prevent layout shift, using the native CSS aspect-ratio property.

Subscription Included with the Velocity Components subscription.
bash
$ velocityx add aspect-ratio-box

Needs a licence key — subscribe here, then velocityx loginonce.

Free MIT licensed. Install it with the CLI — no account, no key.
bash
$ velocityx add aspect-ratio-box@1.0.0

Built for astro.

Full docs for Aspect-Ratio Media Box →

astro
Aspect-Ratio Media Box

16/9

1/1

3/4

Props

NameTypeRequiredDefaultDescription
as'div' | 'figure'No'div'
ratiostringNo'16/9'
roundedbooleanNotrue
classNamestringNo''

File this creates

The CLI writes this path into your project, relative to its root — nothing else moves.

text
components/velocity/aspect-ratio-box/AspectRatioBox.astro

Using the Aspect-Ratio Media Box component

Install it with velocityx add aspect-ratio-box. The CLI writes the source straight into your project — no runtime dependency, no registry lock-in, and it themes itself from the same primary-*/accent-* scale as the rest of the library.

More from Bento & Layout.