# Aspect Ratio (Lumen Halo): prompt.md (v1.0.0)

- id: `lumen-aspect-ratio` · version 1.0.0 · component · free
- category: Layout
- build: Base UI (this item also ships a Radix build)
- install (this build): `npx shadcn@latest add https://beautiful-ui.dev/r/lumen-aspect-ratio.json`
- npm dependencies: none
- registry dependencies: utils
- docs: https://beautiful-ui.dev/components/lumen-aspect-ratio
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

A box that keeps its shape at any width, for media, maps and charts. shadcn's Aspect Ratio, for Lumen Halo.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: none beyond React (Base UI build); `radix-ui@^1` (Radix build).
- Files: `components/ui/lumen/aspect-ratio.tsx`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn).
- Builds: separate Base UI and Radix files. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `AspectRatio`, and every exported type.
- CSS: the install adds the lumen foundation (tokens, keyframes, motion levels) to your global stylesheet once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--lumen-*` custom properties (`--lumen-accent`, `--lumen-accent-text`, `--lumen-bad`, `--lumen-bad-text`, `--lumen-focus`, `--lumen-good`, `--lumen-good-text`, `--lumen-hairline`, `--lumen-ink`, `--lumen-muted-ink`, `--lumen-series-1`, `--lumen-series-2`, `--lumen-series-3`, `--lumen-series-4`, `--lumen-series-5`, `--lumen-series-6`, `--lumen-warn`, `--lumen-warn-text`). Never add Tailwind colour classes inside the component.

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

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `AspectRatio` | `aspect-ratio` | The box. |

Style a part with `[data-slot="<slot>"]` selectors or its `className`; keep the attributes when editing.

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `GlassSoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/glass-sound.json`, import from `@/components/beautiful-ui/glass-sound`); `GlassSoundToggle` is its mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/lumen/aspect-ratio.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- aspect ratio, ratio box, 16:9, media container, shadcn aspect ratio, Lumen
- Images, video and charts that must keep their shape

### Not when
- Content that should grow with its text

## Mistakes
- Put the media inside with full width and height

## Usage

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

<AspectRatio ratio={16 / 9}>…</AspectRatio>
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `ratio` | `number` |  | Width over height, e.g. 16 / 9. |

Full docs: https://beautiful-ui.dev/components/lumen-aspect-ratio

## Customising
- Colours: set the `--lumen-*` tokens on `:root`, or on a container with the `lumen-scope` class to retheme one area. Add the `lumen-inherit` class to follow your shadcn palette instead (`--chart-N`, `--destructive`).
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| — | Not focusable |

## Motion inventory

| Interaction | What moves |
|---|---|
| None | Still |

## Accessibility contract (preserve when editing)
- A plain box

## Install

Base UI project (a base-* style in components.json):

```bash
npx shadcn@latest add https://beautiful-ui.dev/r/lumen-aspect-ratio.json
```

Radix project (a radix-*, new-york or default style):

```bash
npx shadcn@latest add https://beautiful-ui.dev/r/radix-nova/lumen-aspect-ratio.json
```

Or add the `@beautiful-ui` registry to components.json and run `npx shadcn@latest add @beautiful-ui/lumen-aspect-ratio`: the CLI picks the build from your style.

## Credits
- Built on shadcn/ui (https://ui.shadcn.com)

## Source (Base UI build)

### components/ui/lumen/aspect-ratio.tsx

```tsx
/**
 * Aspect Ratio (Lumen Halo) v1.0.0 · Beautiful UI
 * Docs: https://beautiful-ui.dev/components/lumen-aspect-ratio · Agent prompt: https://beautiful-ui.dev/md/lumen-aspect-ratio.md
 * Licensed to the purchaser under the Beautiful UI license: https://beautiful-ui.dev/license
 */
import type * as React from "react";
import { cn } from "@/lib/utils";

/* Lumen Aspect Ratio. shadcn's Aspect Ratio: a box that keeps its shape, for media and charts. Server-safe. */

function AspectRatio({ ratio, className, style, ...props }: React.ComponentProps<"div"> & { ratio: number }) {
  return <div data-slot="aspect-ratio" style={{ "--ratio": ratio, aspectRatio: String(ratio), ...style } as React.CSSProperties} className={cn("relative", className)} {...props} />;
}

export { AspectRatio };
```
