Skip to content
synccn

Model Selector

New

Model picker for the composer: descriptions, capability badges, context size, locked models and full keyboard support.

Ask anything…

Using Smart

Installation

$ pnpm dlx shadcn@latest add @synccn/model-selector

First time in this project? Connect synccn with one command.

Usage

import { ModelSelector } from "@/components/ui/model-selector";<ModelSelector models={models} value={model} onValueChange={setModel} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

ModelSelector

Model picker for chat composers: names, descriptions, capability badges and context size, with full keyboard support.

  • modelsrequired
    AIModel[]

    —

  • value
    string

    Controlled model id.

  • defaultValue
    string

    Model id at first, when uncontrolled. Defaults to the first model.

  • onValueChange
    (id: string) => void

    —

  • align
    "start" | "end"

    Default "start"

    Which edge of the button the menu lines up with.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/hooksuseAutoSide (flips to the side with room), useClickOutside (closes on an outside click), useControllable (works controlled or uncontrolled), useEscape (closes on Escape)
  • lib/utilscn (merges class names)

npm packages

Keyboard

  • ↓or↑Open the menu, or move through models
  • HomeorEndFirst or last model
  • EnterorSpaceChoose the model
  • EscClose and return focus
  • TabClose the menu

Accessibility

  • The menu is a listbox with aria-activedescendant; locked models are aria-disabled and skipped.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: listbox, option
  • ARIA attributes: aria-activedescendant, aria-controls, aria-disabled, aria-expanded, aria-haspopup, aria-label, aria-selected
  • Keys handled: ArrowUp, ArrowDown, Home, End, Enter, Tab, Space
  • Closes with Escape
  • Closes when you click or tap outside
  • Flips to whichever side has room, so it stays on screen