Components › Display

Aspect ratio

Keeps media at a fixed shape as the width changes. Images and video inside crop to fill it.

Installation

npx plankui@latest add aspect-ratio

Usage

import { AspectRatio } from "@/components/ui/aspect-ratio";

<AspectRatio ratio={16 / 9} className="rounded-card">
  <img src="/cover.jpg" alt="" />
</AspectRatio>

API reference

PropTypeDefaultDescription
rationumber16 / 9Width divided by height.

View the source on GitHub