Skip to content

Aspect-Ratio Media Box

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

Bento & Layout · Astro · Subscription · commercial licence · v2.0.0 · updated 2026-10-16 · Live demo

Terminal window
velocityx add aspect-ratio-box

Subscription component. Run velocityx login with your key first — get one.

---
import AspectRatioBox from '../components/velocity/aspect-ratio-box/AspectRatioBox.astro';
---
<AspectRatioBox />
PropTypeDefaultDescription
as'div' | 'figure''div'—
ratiostring'16/9'—
roundedbooleantrue—
fit'cover' | 'contain' | 'fill' | 'none''cover'—
positionstring'center'—
classNamestring''—

velocityx drops these into your project:

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

None.

Colours come from the primary-* / accent-* Tailwind scales, so this drops into a project that is not Velocity without dragging our brand in. Install the contract once:

Terminal window
velocityx theme

Then set your whole brand in one place — raw RGB channels, not hex (a hex here silently breaks every opacity variant):

:root {
--vx-brand: custom;
--vx-primary-600: 220 38 38;
}

There is no component-level font-family anywhere in the library — your font cascade wins.

Commercial, for the duration of an active Velocity X subscription. The source is served by the licence-gated endpoint, never by the public CDN.