# Aspect Ratio · JGuang UI

> Displays content within a desired ratio.

- Page: https://jiguang132.com/systems/jguang-ui/docs/components/radix/aspect-ratio
- Based on: shadcn/ui documentation (MIT) @ bc0705384b51252af26dcc65425b216bf5eb063c

> Example `aspect-ratio-demo`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/aspect-ratio


## Installation


  

**Command**


  

**Manual**


```text
Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.
```


### Install the following dependencies:


```bash
npm install radix-ui
```


### Copy and paste the following code into your project.


[View complete source: components/ui/aspect-ratio.tsx](/r/jguang-ui/radix/aspect-ratio.json)


### Update the import paths to match your project setup.


## Usage

```tsx showLineNumbers
import { AspectRatio } from "@/components/ui/aspect-ratio"
```

```tsx showLineNumbers
<AspectRatio ratio={16 / 9}>
  <Image src="..." alt="Image" className="rounded-md object-cover" />
</AspectRatio>
```

## Square

A square aspect ratio component using the `ratio={1 / 1}` prop. This is useful for displaying images in a square format.


> Example `aspect-ratio-square`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/aspect-ratio


## Portrait

A portrait aspect ratio component using the `ratio={9 / 16}` prop. This is useful for displaying images in a portrait format.


> Example `aspect-ratio-portrait`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/aspect-ratio


## RTL

To enable RTL support in JGuang UI, see the [RTL configuration guide](/systems/jguang-ui/docs/rtl).


> Example `aspect-ratio-rtl`: interactive preview on https://jiguang132.com/systems/jguang-ui/docs/components/radix/aspect-ratio


## API Reference

### AspectRatio

The `AspectRatio` component displays content within a desired ratio.

| Prop        | Type     | Default | Required |
| ----------- | -------- | ------- | -------- |
| `ratio`     | `number` | -       | Yes      |
| `className` | `string` | -       | No       |

For more information, see the [Radix UI documentation](https://www.radix-ui.com/primitives/docs/components/aspect-ratio#api-reference).

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
