---
title: "Aspect Ratio"
description: "Keeps images, videos, and embeds at a fixed width-to-height ratio as the layout resizes."
plan: Free
docs: https://ui.edbn.me/docs/components/aspect-ratio
---

# Aspect Ratio

Keeps images, videos, and embeds at a fixed width-to-height ratio as the layout resizes.

## Installation

```bash
npx shadcn@4.19.0 add https://ui.edbn.me/r/aspect-ratio.json
```

## Dependencies
- edbn: edbn-base

## Usage

```tsx examples/aspect-ratio-basic.tsx
"use client";
import * as React from "react";
import { AspectRatio } from "@/components/ui/aspect-ratio";

function Frame({ children }: { children: React.ReactNode }) {
  return <div className="w-full max-w-sm">{children}</div>;
}

export default function AspectRatioBasicPreview() {
  return (
    <Frame>
      <AspectRatio
        ratio={16 / 9}
        className="grid place-items-center rounded-panel bg-card"
      >
        <span className="text-[13px] text-muted-foreground">16:9</span>
      </AspectRatio>
    </Frame>
  );
}
```

## Files
- components/ui/aspect-ratio.tsx (23 lines)

## For agents
- Base theme, once per project: npx shadcn@4.19.0 add https://ui.edbn.me/r/edbn-base.json
- MCP server with search, items, examples and source: https://ui.edbn.me/mcp
- Every page and item: https://ui.edbn.me/llms.txt
