Files
shadcn-ui/apps/www/content/docs/components/aspect-ratio.mdx

63 lines
1.1 KiB
Plaintext

---
title: Aspect Ratio
description: Displays content within a desired ratio.
component: true
radix:
link: https://www.radix-ui.com/docs/primitives/components/aspect-ratio
api: https://www.radix-ui.com/docs/primitives/components/aspect-ratio#api-reference
---
<ComponentPreview name="aspect-ratio-demo" />
## Installation
<Tabs defaultValue="cli">
<TabsList>
<TabsTrigger value="cli">CLI</TabsTrigger>
<TabsTrigger value="manual">Manual</TabsTrigger>
</TabsList>
<TabsContent value="cli">
```bash
npx shadcn-ui@latest add aspect-ratio
```
</TabsContent>
<TabsContent value="manual">
<Steps>
<Step>Copy and paste the following code into your project.</Step>
<ComponentSource name="aspect-ratio" />
<Step>Update the import paths to match your project setup.</Step>
</Steps>
</TabsContent>
</Tabs>
## Usage
```tsx
import Image from "next/image"
import { AspectRatio } from "@/components/ui/aspect-ratio"
```
```tsx
<div className="w-[450px]">
<AspectRatio ratio={16 / 9}>
<Image
src="..."
alt=Image""
className="rounded-md object-cover"
/>
</AspectRatio>
</div>
```