# AspectRatio

Reserve media space before it arrives, keeping the surrounding reading rhythm steady.

- Family: Layout, imported from `mizu-ui` or `mizu-ui/layout`
- Docs: https://mizu.user64bit.world/components/aspect-ratio
- Source: https://github.com/0xuser64bit/mizu/blob/main/packages/mizu/src/layout/Layout.tsx

## Usage

```tsx
import { AspectRatio } from "mizu-ui";

export function Example() {
  const field = (ground: string, mark: string) =>
    `data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="720" height="360"><pattern id="d" width="36" height="36" patternUnits="userSpaceOnUse"><path d="M18 13l5 5-5 5-5-5z" fill="${mark}"/></pattern><rect width="720" height="360" fill="${ground}"/><rect width="720" height="360" fill="url(#d)"/></svg>`)}`;
  return (
    <AspectRatio ratio={2}>
      <img
        src={field("#141413", "#7e776b")}
        alt="A diamond measurement field"
      />
    </AspectRatio>
  );
}
```

## Copy it with the shadcn CLI

```sh
npx shadcn@latest init 0xuser64bit/mizu/preset # once, where there is no components.json
npx shadcn@latest add 0xuser64bit/mizu/aspect-ratio
```

## Props

- `ratio`: `number` (default `16 / 9`). Width divided by height.
- `children / ...props`: `ReactNode / HTMLAttributes`. Native wrapper and media.

## Accessibility

CSS aspect-ratio reserves space; invalid ratios fall back to a square. Content retains its own accessibility.

## Motion

Static geometry.
