Displays content within a desired ratio.
16:9 Aspect Ratio
import { AspectRatio } from "@/components/ui/aspect-ratio"
import Image from "next/image"
export function AspectRatioDemo() {
return (
<div className="w-[400px]">
<AspectRatio ratio={16 / 9}>
<Image
src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80"
alt="Image"
fill
className="rounded-md object-cover"
/>
</AspectRatio>
</div>
)
}| Prop | Type | Default | Description |
|---|---|---|---|
| ratio | number | 1 | The desired aspect ratio for the content. |