Ravox KitSurfaces

Aspect Ratio

Holds an image, video or iframe at a fixed ratio, so nothing jumps when the media arrives. Shows a placeholder while loading, fades the media in briefly and reports when it fails.

Capa do design Abrigo, landing de pousada

Settings

Razão
Ajuste
Toggles

Examples

Placeholder while loading

Capa do design Brasa, landing de hamburgueria

16/9 video

Grid of square thumbnails

Capa do design Alicerce
Capa do design Caderno
Capa do design Camarim
Capa do design Canteiro
Capa do design Carteira
Capa do design Consulta

Portrait, whole media

Capa do design Delírio

Installation

The command creates components/ui/aspect-ratio.tsx in your project and installs the theme with it. The file is yours: edit it as you like.

npx @ravox-ui/cli add aspect-ratio

Props

PropTypeDefaultDescription
rationumber | `${number}/${number}`16 / 9Width divided by height: 16 / 9, "4/3", 1.
fit"cover" | "contain""cover"Crops the media to fill, or shows it whole with bars.
placeholderReactNode | false—Replaces the loading placeholder (a <Skeleton />, the photo's average color). false removes it.
errorReactNode"Media unavailable"What appears if the <img> or <video> fails.
...propsComponentProps<"div">—Everything a <div> accepts. The <img>, <video> or <iframe> goes in as a direct child.

More in Surfaces