Aspect Ratio
Displays content within a desired ratio.
Overview
AspectRatio keeps children inside a fixed width-to-height frame. Pass ratio as a number such as 16 / 9 or 1. Combine with Tailwind width utilities like max-w-md or sm:max-w-lg. In your app, images and video typically fill the frame with object-cover.
Preview
Customize
Installation
Add the component with the CLI. It copies the files in and installs anything they depend on.
npx vinyaas add aspect-ratioUsage
import { AspectRatio } from "@/components/ui/aspect-ratio";
export function Hero() {
return (
<AspectRatio ratio={16 / 9} className="bg-muted max-w-md overflow-hidden rounded-md">
<div className="text-muted-foreground flex size-full items-center justify-center text-sm">
16:9
</div>
</AspectRatio>
);
}Examples
Landscape
A 16:9 frame for wide media.
Square
A 1:1 frame for avatars and thumbnails.
Portrait
A 9:16 frame for tall media.
Responsive width
Cap the frame with max-width utilities. The ratio stays fixed as the viewport shrinks.
In practice
A marketing card uses AspectRatio for a 16:9 Open Graph cover above title, description, and equally sized actions.

Composable React components you install as source.
A production catalog for forms, overlays, charts, and product UI — with docs, CLI install, and theme tokens that travel with your app.
API
Other attributes for the underlying element are passed through.
| Name | Type | Default | Description |
|---|---|---|---|
ratio | number | — | Width divided by height. Use 16 / 9, 1, or 9 / 16. |
className | string | — | Merged onto the aspect ratio root with cn. |
Accessibility
AspectRatio is presentational. Give images meaningful alt text. Decorative crops can use an empty alt when the surrounding copy already describes the media.