# AspectRatio

> Keeps its content at a fixed width-to-height ratio.

- Category: [Window & layout](https://tarve.dev/docs.md#layout)
- Import: `import { AspectRatio } from "@tarve/core";`
- Props type: `AspectRatioProps`
- Source: [packages/core/src/form-controls.ts:55](https://github.com/omarcosr/tarve/blob/main/packages/core/src/form-controls.ts#L55)

## Usage

```tsx title="AspectRatio.tsx"
import { AspectRatio, Image } from "@tarve/core";

<AspectRatio ratio={16 / 9} width={480}>
  <Image src="assets/cover.png" fit="cover" />
</AspectRatio>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `ratio` (required) | `number` | — |  |
| `width` | `Style["width"]` | `320` |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

Previous: [Resizable](https://tarve.dev/docs/components/Resizable.md) · Next: [Direction](https://tarve.dev/docs/components/Direction.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/AspectRatio · Index for agents: https://tarve.dev/llms.txt
