Skip to content
Haze UI

AI model selector

Expandable model pill with four AI models and an adaptive detent effort track that reshapes stops while preserving effort preference.

pnpm dlx shadcn@latest add @haze/ai-model-selector
Open preview in a new tab
Livesmall script

When to use

  • Pairing model selection with model-specific reasoning effort stops inside an AI toolbar
  • Showing context window and latency metadata alongside an adaptive segmented effort control
  • Preserving a user's preferred effort rank while smoothly clamping to the nearest valid stop

When not to use

  • Every model shares identical static options without dynamic stop reshaping; use model-picker or segmented-control instead

Installation

Add the Haze registry to components.json once, then install AI model selector with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.

pnpm dlx shadcn@latest add @haze/ai-model-selector
First time? Registry and theme setup

1. Add to components.json:

{
  "registries": {
    "@haze": "http://localhost:4329/r/{name}.json"
  }
}

2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";

API reference

PropTypeDefaultDescription
idstring"haze-ai-model-selector"Unique prefix for heading and panel aria-controls.
headingstring"AI model selector"Screen-reader section heading for the model selector.
models{ id: string; name: string; summary: string; stops: string[]; badge?: string }[]4 demo modelsModel definitions including summary copy and adaptive effort stops.
initialModelstring"opus"ID of the initially active model.
initialEffortstring"High"Initial effort stop selected on load.
classstring–Extra classes on the outer section.

Keyboard interactions

EnterSpace
Expand or collapse the selector panel and select a model or effort stop
ArrowLeftArrowRight
Step across the active model's effort stops on the detent track

Accessibility

  • The pill trigger uses aria-expanded and aria-controls, while both the model list and effort track expose radiogroup and radio semantics.
  • Model switches and effort stop clamping announce cleanly through a polite role="status" live region.

Notes for AI

Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.

  • Install and use

    Install the Haze UI block "AI model selector" with `npx shadcn@latest add @haze/ai-model-selector`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import AiModelSelector from "@/components/haze/blocks/ai-model-selector.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/blocks/ai-model-selector.md

  • Customize with real content

    Adapt the Haze ai-model-selector block for our product. Replace the demo values of these props with our real content: id, heading, models, initialModel, initialEffort, class. Keep the layout, the heading level rules and these accessibility details: The pill trigger uses aria-expanded and aria-controls, while both the model list and effort track expose radiogroup and radio semantics. Model switches and effort stop clamping announce cleanly through a polite role="status" live region. Do not add raw color classes; use the Haze tokens.

  • Choose the right block

    Before using ai-model-selector, check it fits: use it when pairing model selection with model-specific reasoning effort stops inside an ai toolbar; showing context window and latency metadata alongside an adaptive segmented effort control; preserving a user's preferred effort rank while smoothly clamping to the nearest valid stop. Avoid it when every model shares identical static options without dynamic stop reshaping; use model-picker or segmented-control instead. Alternatives: @haze/model-picker, @haze/ai-prompt, @haze/segmented-control.

Dependencies

  • npm: @lucide/astro
  • @haze/utils
  • @haze/theme (one-time setup)

Source · Original Haze UI work.

Catalog

↑↓ moveEnter openEsc close

Keyboard shortcuts

CtrlK
Command palette
/
Focus search
←↑→↓
Move between cards
jk
Next / previous card
ci
Copy code / install command (detail page)
[]
Previous / next entry
?
This help
Esc
Close dialog