Aspect Ratio
A responsive container component that maintains a fixed aspect ratio, commonly used for media like images and videos.
Installation
npx scrollx-ui@latest add aspect-ratio
Usage
import Image from "next/image"
import { AspectRatio } from "@/components/ui/aspect-ratio"
<div className="w-[450px]">
<AspectRatio ratio={16 / 9}>
<Image src="..." alt="Image" className="rounded-md object-cover" />
</AspectRatio>
</div>
API Reference
AspectRatio
The root container for the AspectRatio
component, which helps to maintain a consistent aspect ratio for its child content, like images or videos.