# Model picker

> The model pill in your composer grows into the menu: what each model is for, speed, smarts and thinking effort.

Choosing a model shouldn’t mean reading a spec sheet in a dropdown. The pill in the composer toolbar shows the model and its thinking effort, and both morph when they change: the name’s shared letters glide, the effort word slides in for reasoning models and folds away for the rest, and the icon trades places through a blur. Click it and the same surface lifts out of the composer and grows into the menu above it, never over your prompt: its size and corners ease from pill to panel while the label cross-fades into the list. Each model gets a line on what it’s for and small speed and smarts meters. Reasoning models add a Thinking control, and the panel’s height follows. Paid models show "Pro" and hand off to your upgrade flow.

## Install

```bash
npx shadcn@latest add https://hairlineui.com/r/model-picker.json
```

Needs React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

- npm: `lucide-react`
- Hairline UI components it needs (the CLI installs them too): `text-morph`
- Docs and live preview: https://hairlineui.com/ui/model-picker
- Registry item (source): https://hairlineui.com/r/model-picker.json

## Usage

```tsx
import { ModelPicker } from "@/components/model-picker";

<ModelPicker
  models={[
    { id: "openai/gpt-5-mini", name: "GPT-5 mini", description: "Fast, everyday questions", speed: 3, intelligence: 2 },
    { id: "openai/gpt-5", name: "GPT-5", description: "Reasons before it answers", speed: 1, intelligence: 3, reasoning: true },
  ]}
  value={model}
  onValueChange={setModel}
  effort={effort}
  onEffortChange={setEffort}
  align="end" // beside Send, growing from the right edge
  anchorRef={composerRef} // opens above the composer, never over it
/>
```

## With the AI SDK

```tsx
"use client";
import { useState } from "react";
import { useChat } from "@ai-sdk/react";
import { ModelPicker } from "@/components/model-picker";

export function Composer() {
  const [model, setModel] = useState("openai/gpt-5-mini");
  const [effort, setEffort] = useState("Medium");
  const { sendMessage } = useChat();
  // …your input; when it sends:
  const send = (text: string) => sendMessage({ text }, { body: { model, effort: effort.toLowerCase() } });

  return <ModelPicker models={MODELS} value={model} onValueChange={setModel} effort={effort} onEffortChange={setEffort} />;
}

// app/api/chat/route.ts: model ids go straight to the AI Gateway
import { convertToModelMessages, streamText } from "ai";

const ALLOWED = new Set(MODELS.filter((m) => !m.locked).map((m) => m.id));

export async function POST(req: Request) {
  const { messages, model, effort } = await req.json();
  if (!ALLOWED.has(model)) return new Response("Unknown model", { status: 400 });
  const result = streamText({
    model,
    messages: convertToModelMessages(messages),
    providerOptions: { openai: { reasoningEffort: effort } },
  });
  return result.toUIMessageStreamResponse();
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `models` | `{ id; name; description?; icon?; speed?; intelligence?; reasoning?; locked? }[]` | – | speed and intelligence are 1 to 3. reasoning adds the Thinking control; locked shows "Pro". |
| `value / onValueChange` | `string / (id: string) => void` | – | The selected model. |
| `effort / onEffortChange` | `string / (effort: string) => void` | – | Thinking effort for reasoning models; the control appears when onEffortChange is set. |
| `efforts` | `string[]` | `["Low", "Medium", "High"]` | The effort levels. |
| `onLockedSelect` | `(model) => void` | – | Called instead of selecting a locked model. Without it, locked models are disabled. |
| `side / align` | `"top" \| "bottom" / "start" \| "end"` | `"top" / "start"` | Grow upward or downward, from the pill’s left or right edge. |
| `anchorRef` | `RefObject<HTMLElement>` | – | Open clear of this element, e.g. your composer, lined up with its edge, instead of over it. Without it, the panel opens just above the pill. |
| `collisionPadding` | `number` | `16` | Space kept from the screen edges. On narrow screens the panel narrows and shifts to stay fully visible. |

## States

- **closed**: A quiet pill: icon, model name, and the effort for reasoning models, e.g. "Aurora Think Medium". A new model or effort morphs in place ("Medium" → "High"); the effort opens or folds over 380ms as reasoning comes and goes.
- **open**: The pill lifts clear of the composer and grows into a 340px panel above it, lined up with its edge. The current model is checked and a highlight slides with the pointer or arrow keys.
- **effort**: For reasoning models, a Thinking control (Low, Medium, High) with a sliding thumb. The panel grows to fit it.
- **locked**: "Pro" instead of a check. Choosing it calls onLockedSelect, e.g. to open pricing, and keeps the current model.
- **closing**: The panel folds back into the pill; focus returns to it.

## What it handles

Choosing a model should not mean reading a spec sheet in a dropdown. This pill grows into a menu that says what each model is for and lets people set the thinking effort.

- **The pill shows model and effort**: The model name and effort morph when they change, for example “Medium” to “High”.
- **What each model is for**: Each model has a line of description and small speed and smarts meters, with text for screen readers.
- **Thinking effort**: Reasoning models add a Low, Medium, High control. Pass your own levels.
- **Pro models stay visible**: Locked models show “Pro”, and choosing one calls onLockedSelect instead of switching.
- **It opens clear of your prompt**: With anchorRef the panel opens above the composer without covering it, and on narrow screens it narrows and shifts to stay in view.
- **Keyboard friendly**: Arrow keys, Home and End move, Enter picks and Escape closes and returns focus to the pill.

## Replaces

a model dropdown, model descriptions, speed and quality indicators, a thinking effort control, a locked Pro state, popover positioning

## Where it fits

- **AI chat composers**: Choose the model beside the Send button.
- **Agent settings**: Set the default model and thinking effort for an agent.
- **Prompt playgrounds**: Compare models by what each is for and how fast it is.
- **Plan-gated AI features**: Show Pro models locked, and send people to upgrade.

## Notes

- Put it beside Send with align="end": the model is a setting on how the message goes out, and the panel then lines up with the composer’s right edge.
- The pill is a button with aria-haspopup="listbox"; the list takes focus when open, and the active row is announced through aria-activedescendant.
- Arrow keys, Home and End move; Enter or Space picks; Escape closes and returns focus to the pill. Tab reaches the Thinking control, a radio group you move through with the arrow keys.
- Meters have text for screen readers ("Speed 2 of 3"), so they don’t rely on the dots alone.
- Always check the model id on the server; the picker only offers choices.
- Installs Text morph. With reduced motion, it opens, closes and changes its label instantly.

License: MIT (https://hairlineui.com/license#components)
