Aspect Ratio
Displays content within a desired ratio.
Installation
›pnpm dlx shadcn@latest add @evolphin/aspect-ratio
Usage
import { AspectRatio } from "@/components/ui/aspect-ratio"<AspectRatio ratio={16 / 9}>
<img src="..." alt="Image" className="rounded-md object-cover" />
</AspectRatio>Type Definitions
interface AspectRatioProps {
/** The desired ratio */
ratio?: number;}Examples
Default
1:1 Ratio
API Reference
AspectRatio
| Prop | Type | Default | Description |
|---|---|---|---|
ratio | number | 1 | The desired aspect ratio. |
asChild | boolean | false | Change the component to the HTML tag or custom component of the only child. |