# Ratio Picker

Aspect-ratio selector displaying to-scale glyphs inside a fixed square frame.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available by appending `.md` to any URL or sending an `Accept: text/markdown` header. An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

<ComponentPreview name="ratio-picker">
  <RatioPickerDemo />
</ComponentPreview>

## Installation [#installation]

```bash
npx shadcn@latest add https://motif.sweetretry.com/r/ratio-picker.json
```

## Usage [#usage]

```tsx
import { RatioPicker } from "@/components/ui/motif/ratio-picker";

export function Frame() {
  const [ratio, setRatio] = useState("16:9");

  return (
    <div className="space-y-2">
      <div className="font-medium text-muted-foreground text-xs">
        Aspect ratio
      </div>
      <RatioPicker
        aria-label="Aspect ratio"
        onChange={setRatio}
        value={ratio}
      />
    </div>
  );
}
```

- Renders no label; pass `aria-label` alongside your own heading.
- Pass custom `options` when needed (`"adaptive"` and `"auto"` render a scan glyph); `RatioIcon` is exported standalone for triggers or badges.
- `showReferenceBox` draws a dashed square frame around the selected glyph.

```tsx
<RatioPicker
  aria-label="Canvas"
  options={["1:1", "16:9", "9:16", "adaptive"]}
  value={ratio}
  onChange={setRatio}
/>
```

<RatioPickerAdaptiveDemo />

## Accessibility [#accessibility]

- Renders `role="group"` named by `aria-label` with `<button aria-pressed>` cells; glyphs are `aria-hidden`.

## Component source [#component-source]

<ComponentSource
  name="ratio-picker"
  src="registry/new-york/ratio-picker.tsx"
  title="ratio-picker.tsx"
/>
