Frame
The field is the picture.
Keeps media at a defined aspect ratio while it fills the available box.
The field is the picture.
Three ways in. They share one source, so the pixels match whichever you pick.
npm install @noorddev/vlak-react
// once, next to your app's root
import "@noorddev/vlak-react/css";
import { AspectRatio } from "@noorddev/vlak-react";Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/aspect-ratio.
npx @noorddev/vlak-cli add aspect-ratio
The StyleX leaf lands in components/vlak/, for your own compiler to own. See StyleX.
npx shadcn add https://vlak.dev/r/aspect-ratio.json
The same registry item, installed by shadcn's CLI.
<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />
No React. Link vlak.css and use the markup and classes below.
import { AspectRatio } from "@noorddev/vlak-react";
<AspectRatio ratio={16 / 9}>
<img src="/cover.jpg" alt="Press hall" />
</AspectRatio>| Prop | Type | Default | Description |
|---|---|---|---|
ratio | number | 16 / 9 | Width over height, e.g. 16 / 9. |
Also accepts HTMLAttributes<HTMLDivElement>.
<div class="rs-ratio" style="aspect-ratio:16/9;max-width:280px;background:var(--divider-subtle)"></div>