Model picker
Pick a model by speed, smarts and context.
Installation
Run the CLI
Run
pnpm dlx asta-ui@latest initonce, then this. The file lands incomponents/astabyte/and the colour tokens go into your CSS.$ pnpm dlx asta-ui@latest add model-pickerOr install the package
Don’t want the file? Import from
asta-ui/model-pickerand update withpnpm update asta-ui. Add the stylesheet once. More.$ pnpm add asta-uiimport { ModelPicker } from "asta-ui/model-picker";Or copy it by hand
Copy this file. Keep the paths, or fix the
@/imports. Then add the tokens fromglobals.css."use client"; import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent } from "react"; const cx = (...c: (string | false | null | undefined)[]) => c.filter(Boolean).join(" "); export interface ModelOption { value: string; label: string; /** Family heading the model sits under, e.g. "Astra 2". Models keep their order inside a group. */ group?: string; /** One line about what it is good at. */ hint?: string; /** Short tag next to the name in the trigger, e.g. "Pro" or "Fast". */ tag?: string; /** 1 to 5. */ speed: number; /** 1 to 5. */ intelligence: number; /** Context window label, e.g. "200K". */ context?: string; isNew?: boolean; disabled?: boolean; /** Why it is disabled, shown instead of the hint. */ disabledReason?: string; } export interface ModelPickerProps { models: ModelOption[]; value?: string; defaultValue?: string; onChange?: (value: string) => void; /** Accessible name of the trigger and the list. */ label?: string; /** Show a search field at the top of the list. Default true. */ searchable?: boolean; /** `field` is a bordered select, `chip` a quiet trigger for toolbars (e.g. inside a prompt composer). */ variant?: "field" | "chip"; /** Where the list opens. Default bottom. */ side?: "bottom" | "top"; align?: "start" | "end"; /** Form field name, submitted as a hidden input. */ name?: string; disabled?: boolean; className?: string; } const KEYFRAMES = `@keyframes asta-mp-in { from { opacity: 0; transform: translateY(var(--asta-mp-y, -4px)) scale(.97) } } @media (prefers-reduced-motion: reduce) { .asta-mp, .asta-mp * { animation: none !important; transition-duration: 0s !important } }`; const ROW = 56; const BAR = 22; const EASE = "cubic-bezier(.16,1,.3,1)"; const icon = { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.25, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true } as const; const SPEED = "M13.5 3 5.5 13.5h6L10.5 21l8-10.5h-6Z"; const SMART = "M12 3.5c.7 4.6 2.4 6.3 7 7-4.6.7-6.3 2.4-7 7-.7-4.6-2.4-6.3-7-7 4.6-.7 6.3-2.4 7-7ZM19 16.5c.25 1.6.9 2.25 2.5 2.5-1.6.25-2.25.9-2.5 2.5-.25-1.6-.9-2.25-2.5-2.5 1.6-.25 2.25-.9 2.5-2.5Z"; function Dots({ n, label }: { n: number; label: string }) { const v = Math.max(0, Math.min(5, Math.round(n))); return ( <span className="flex items-center gap-[3px]"> <span className="sr-only">{`${label} ${v} of 5.`}</span> {[0, 1, 2, 3, 4].map((i) => ( <span key={i} aria-hidden className={cx("h-[5px] w-[5px] rounded-full", i < v ? "bg-ink" : "bg-[color-mix(in_srgb,var(--color-ink)_14%,transparent)]")} /> ))} </span> ); } /** * A select for AI models. The list is grouped by family and every row shows a one-line hint, speed and * intelligence dots, the context size and a New badge. Search filters as you type. Arrows, Home/End, * Enter and Escape work, and without search, typing jumps to a model. The selection mark slides between rows. */ export function ModelPicker({ models, value, defaultValue, onChange, label = "Model", searchable = true, variant = "field", side = "bottom", align = "start", name, disabled, className, }: ModelPickerProps) { const [inner, setInner] = useState(defaultValue ?? models.find((m) => !m.disabled)?.value ?? ""); const current = value ?? inner; const [open, setOpen] = useState(false); const [query, setQuery] = useState(""); const [active, setActive] = useState(-1); const root = useRef<HTMLDivElement>(null); const trigger = useRef<HTMLButtonElement>(null); const search = useRef<HTMLInputElement>(null); const list = useRef<HTMLDivElement>(null); const hl = useRef<HTMLSpanElement>(null); const bar = useRef<HTMLSpanElement>(null); const pop = useRef<HTMLDivElement>(null); const placed = useRef(false); const typed = useRef({ text: "", at: 0 }); const uid = useId(); const selected = models.find((m) => m.value === current); const q = query.trim().toLowerCase(); const shown = useMemo( () => (q ? models.filter((m) => `${m.label} ${m.group ?? ""} ${m.hint ?? ""} ${m.tag ?? ""}`.toLowerCase().includes(q)) : models), [models, q], ); // Groups in first-seen order, and the visual order of rows for keyboard movement. const groups = useMemo(() => { const out: { name: string; items: { m: ModelOption; i: number }[] }[] = []; shown.forEach((m, i) => { const g = m.group ?? ""; let bucket = out.find((x) => x.name === g); if (!bucket) out.push((bucket = { name: g, items: [] })); bucket.items.push({ m, i }); }); return out; }, [shown]); const order = useMemo(() => groups.flatMap((g) => g.items.map((x) => x.i)), [groups]); const usable = order.filter((i) => !shown[i].disabled); // After filtering, fall back to the first enabled match. const act = usable.includes(active) ? active : (usable[0] ?? -1); const step = (dir: 1 | -1) => { if (!usable.length) return; const k = usable.indexOf(act); setActive(usable[(k + dir + usable.length) % usable.length]); }; const show = (seed = "") => { if (disabled) return; placed.current = false; setQuery(seed); setActive(seed ? -1 : models.findIndex((m) => m.value === current)); setOpen(true); }; const hide = (refocus = true) => { setOpen(false); setQuery(""); if (refocus) trigger.current?.focus(); }; const pick = (m: ModelOption | undefined) => { if (!m || m.disabled) return; if (value === undefined) setInner(m.value); onChange?.(m.value); hide(); }; // Focus the search field (or the list) when the popup opens. useEffect(() => { if (open) (searchable ? search.current : list.current)?.focus({ preventScroll: true }); }, [open, searchable]); // Keep the popup inside the viewport with a 16px gutter (narrow phones, or a chip near the edge). useLayoutEffect(() => { const el = pop.current; if (!open || !el) return; el.style.translate = ""; const r = el.getBoundingClientRect(); const dx = r.left < 16 ? 16 - r.left : r.right > window.innerWidth - 16 ? window.innerWidth - 16 - r.right : 0; if (dx) el.style.translate = `${Math.round(dx)}px 0`; }, [open]); // Slide the hover highlight and the selection bar to their rows. Measured when they change, never per frame. useLayoutEffect(() => { const box = list.current; if (!open || !box || !hl.current || !bar.current) return; const row = (i: number) => (i < 0 ? null : box.querySelector<HTMLElement>(`[data-i="${i}"]`)); const a = row(act); const s = row(shown.findIndex((m) => m.value === current)); const first = !placed.current; for (const el of [hl.current, bar.current]) el.style.transition = first ? "none" : `transform ${el === bar.current ? 300 : 200}ms ${EASE}, opacity 200ms ${EASE}`; hl.current.style.opacity = a ? "1" : "0"; if (a) hl.current.style.transform = `translateY(${a.offsetTop}px)`; bar.current.style.opacity = s ? "1" : "0"; if (s) bar.current.style.transform = `translateY(${s.offsetTop + (ROW - BAR) / 2}px)`; placed.current = true; a?.scrollIntoView({ block: "nearest" }); }, [open, act, shown, current]); useEffect(() => { if (!open) return; const onDown = (e: PointerEvent) => { if (!root.current?.contains(e.target as Node)) { setOpen(false); setQuery(""); } }; document.addEventListener("pointerdown", onDown); return () => document.removeEventListener("pointerdown", onDown); }, [open]); const onListKey = (e: KeyboardEvent<HTMLElement>) => { if (e.key === "ArrowDown") step(1); else if (e.key === "ArrowUp") step(-1); else if (e.key === "Home" && !searchable) setActive(usable[0] ?? -1); else if (e.key === "End" && !searchable) setActive(usable[usable.length - 1] ?? -1); else if (e.key === "Enter") pick(shown[act]); else if (e.key === "Escape") hide(); else if (e.key === "Tab") return hide(false); else if (!searchable && e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) { // Typeahead: jump to the first model whose name starts with what was typed. const now = Date.now(); typed.current = { text: (now - typed.current.at < 700 ? typed.current.text : "") + e.key.toLowerCase(), at: now }; const t = typed.current.text; const hit = usable.find((i) => shown[i].label.toLowerCase().startsWith(t)) ?? usable.find((i) => shown[i].label.toLowerCase().includes(t)); if (hit !== undefined) setActive(hit); } else return; e.preventDefault(); }; const listId = `${uid}-list`; const activeId = open && act >= 0 ? `${uid}-o-${act}` : undefined; const chip = variant === "chip"; return ( <div ref={root} className={cx("asta-mp relative", chip ? "inline-flex" : "w-full", className)}> <style href="asta-model-picker" precedence="asta">{KEYFRAMES}</style> <button ref={trigger} type="button" disabled={disabled} aria-haspopup="listbox" aria-expanded={open} aria-controls={open ? listId : undefined} aria-label={`${label}: ${selected?.label ?? "none"}`} onClick={() => (open ? hide() : show())} onKeyDown={(e) => { if (open) return; if (e.key === "ArrowDown" || e.key === "ArrowUp") { e.preventDefault(); show(); } else if (searchable && e.key.length === 1 && e.key !== " " && !e.metaKey && !e.ctrlKey && !e.altKey) { // Typing on the closed trigger opens the list and starts a search. e.preventDefault(); show(e.key); } }} className={cx( "flex items-center gap-2 text-left outline-none transition-[background-color,box-shadow,color] duration-200", "focus-visible:ring-2 focus-visible:ring-brand/50 disabled:cursor-not-allowed disabled:opacity-45", chip ? "h-8 max-w-[220px] rounded-md px-2 text-[13px] text-ink-2 hover:bg-paper-2 hover:text-ink aria-expanded:bg-paper-2 aria-expanded:text-ink" : "h-10 w-full rounded-lg bg-paper px-3 text-[14px] text-ink shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_14%,transparent)] hover:shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--color-ink)_24%,transparent)] aria-expanded:shadow-[inset_0_0_0_1px_var(--color-brand),0_0_0_3px_color-mix(in_srgb,var(--color-brand)_18%,transparent)]", )} > <svg {...icon} className="h-3.5 w-3.5 shrink-0 text-brand" fill="currentColor" stroke="none"> <path d="M12 3.5c.7 4.6 2.4 6.3 7 7-4.6.7-6.3 2.4-7 7-.7-4.6-2.4-6.3-7-7 4.6-.7 6.3-2.4 7-7Z" /> <path d="M19 16.5c.25 1.6.9 2.25 2.5 2.5-1.6.25-2.25.9-2.5 2.5-.25-1.6-.9-2.25-2.5-2.5 1.6-.25 2.25-.9 2.5-2.5Z" /> </svg> <span className="min-w-0 truncate font-medium">{selected?.label ?? "Choose a model"}</span> {selected?.tag && ( <span className="shrink-0 rounded-[5px] bg-[color-mix(in_srgb,var(--color-ink)_7%,transparent)] px-1.5 py-px text-[11px] font-medium text-ink-2">{selected.tag}</span> )} <svg {...icon} className={cx("ml-auto h-3.5 w-3.5 shrink-0 text-mute transition-transform duration-300 ease-[cubic-bezier(.16,1,.3,1)]", open && "rotate-180")}> <path d={side === "top" ? "M6 14.5l6-6 6 6" : "M6 9.5l6 6 6-6"} /> </svg> </button> {name && <input type="hidden" name={name} value={current} />} {open && ( <div ref={pop} className={cx( "absolute z-50 flex w-[372px] max-w-[calc(100vw-32px)] flex-col overflow-hidden rounded-xl bg-paper", "shadow-[0_0_0_1px_color-mix(in_srgb,var(--color-ink)_10%,transparent),0_16px_40px_-12px_rgb(0_0_0/0.25),0_4px_10px_-6px_rgb(0_0_0/0.1)]", "animate-[asta-mp-in_.18s_cubic-bezier(.16,1,.3,1)_both]", side === "top" ? "bottom-full mb-1.5 origin-bottom [--asta-mp-y:4px]" : "top-full mt-1.5 origin-top", align === "end" ? "right-0" : "left-0", )} > {searchable && ( <div className="flex items-center gap-2 px-3 pt-2.5 pb-1.5"> <svg {...icon} className="h-4 w-4 shrink-0 text-mute"> <circle cx="10.5" cy="10.5" r="6" /> <path d="m15 15 5 5" /> </svg> <input ref={search} type="search" role="combobox" aria-label={`Search ${label.toLowerCase()}s`} aria-expanded aria-controls={listId} aria-autocomplete="list" aria-activedescendant={activeId} autoComplete="off" spellCheck={false} enterKeyHint="go" placeholder="Search models…" value={query} onChange={(e) => setQuery(e.target.value)} onKeyDown={onListKey} className="h-8 min-w-0 flex-1 bg-transparent text-[16px] text-ink outline-none placeholder:text-mute sm:text-[13.5px] [&::-webkit-search-cancel-button]:hidden" /> </div> )} <div ref={list} id={listId} role="listbox" aria-label={label} tabIndex={searchable ? undefined : -1} aria-activedescendant={searchable ? undefined : activeId} onKeyDown={searchable ? undefined : onListKey} onPointerDown={(e) => searchable && e.preventDefault()} className="relative max-h-[min(360px,60vh)] overflow-y-auto overscroll-contain p-1.5 outline-none [scrollbar-width:thin]" > {/* The hover highlight and the selection bar slide on transform. */} <span ref={hl} aria-hidden className="pointer-events-none absolute inset-x-1.5 top-0 rounded-lg bg-paper-2 opacity-0" style={{ height: ROW }} /> <span ref={bar} aria-hidden className="pointer-events-none absolute left-1.5 top-0 z-[1] w-[3px] rounded-full bg-brand opacity-0" style={{ height: BAR }} /> {groups.map((g) => ( <div key={g.name || "_"} role="group" aria-labelledby={g.name ? `${uid}-g-${g.name}` : undefined} aria-label={g.name ? undefined : label}> {g.name && ( <p id={`${uid}-g-${g.name}`} className="relative px-3.5 pt-2.5 pb-1 font-mono text-[10.5px] uppercase tracking-wider text-mute"> {g.name} </p> )} {g.items.map(({ m, i }) => { const on = m.value === current; return ( <div key={m.value} id={`${uid}-o-${i}`} data-i={i} role="option" aria-selected={on} aria-disabled={m.disabled || undefined} onPointerMove={() => !m.disabled && act !== i && setActive(i)} onClick={() => pick(m)} className={cx("relative flex select-none items-center gap-3 rounded-lg pl-3.5 pr-2.5", m.disabled ? "cursor-not-allowed" : "cursor-pointer")} style={{ height: ROW }} > <span className={cx("min-w-0 flex-1", m.disabled && "opacity-55")}> <span className="flex items-center gap-1.5"> <span className={cx("truncate text-[13.5px] font-medium", on ? "text-ink" : "text-ink-2")}>{m.label}</span> {m.isNew && <span className="shrink-0 rounded-[5px] bg-brand px-1.5 text-[10px] font-semibold leading-[16px] text-on-brand">New</span>} </span> <span className="mt-0.5 block truncate text-[12px] text-mute">{m.disabled ? (m.disabledReason ?? "Not available") : m.hint}</span> </span> <span className={cx("flex shrink-0 flex-col items-end gap-1.5", m.disabled && "opacity-55")}> <span className="flex items-center gap-1.5" title="Speed"> <svg {...icon} className="h-3 w-3 text-mute"> <path d={SPEED} /> </svg> <Dots n={m.speed} label="Speed" /> </span> <span className="flex items-center gap-1.5" title="Intelligence"> <svg {...icon} className="h-3 w-3 text-mute"> <path d={SMART} /> </svg> <Dots n={m.intelligence} label="Intelligence" /> </span> </span> <span className={cx("w-9 shrink-0 text-right font-mono text-[11px] tabular-nums text-mute", m.disabled && "opacity-55")} title="Context window"> {m.context && <span className="sr-only">Context window </span>} {m.context} </span> <svg {...icon} strokeWidth={3} className={cx("h-3.5 w-3.5 shrink-0 text-brand transition-[opacity,transform] duration-200 ease-[cubic-bezier(.16,1,.3,1)]", on ? "scale-100 opacity-100" : "scale-75 opacity-0")} > <path d="M5 12.5l4.5 4.5L19 7.5" /> </svg> </div> ); })} </div> ))} {shown.length === 0 && ( <div role="presentation" className="flex flex-col items-center gap-1 px-3 py-8 text-center"> <span className="text-[13px] font-medium text-ink-2">No models found</span> <span className="text-[12px] text-mute">Nothing matches “{query.trim()}”. Try a family name.</span> </div> )} </div> <div className="hidden items-center gap-3 bg-paper-2 px-3.5 py-2 text-[11.5px] text-mute sm:flex"> <span className="flex items-center gap-1.5"> <svg {...icon} className="h-3 w-3"> <path d={SPEED} /> </svg> Speed </span> <span className="flex items-center gap-1.5"> <svg {...icon} className="h-3 w-3"> <path d={SMART} /> </svg> Intelligence </span> <span className="ml-auto">↑↓ to move · Enter to pick</span> </div> </div> )} </div> ); } export default ModelPicker;Or ask your AI agent
Paste this into Claude Code, Cursor, Codex, v0 or Lovable. Fill in the last line. More in Prompts.
Add the Astabyte UI Model picker component to my project. Pick a model by speed, smarts and context. It includes: search, groups, meters, badges, sliding mark, typeahead, keys. Install it: ```sh pnpm dlx asta-ui@latest add model-picker --radix ``` Or with the shadcn CLI: ```sh pnpm dlx shadcn@latest add https://ui.astabyte.com/r/model-picker.json ``` If the project isn't set up yet, run `pnpm dlx asta-ui@latest init --radix` first: it runs `shadcn init` when needed and adds the @astabyte registry (Next.js, Vite, React Router, Astro, TanStack Start; Tailwind CSS v4). Import it like this: ```tsx import { ModelPicker, type ModelOption } from "@/components/astabyte/model-picker"; ``` Usage example and props: https://ui.astabyte.com/model-picker Full catalogue for context: https://ui.astabyte.com/llms.txt Rules: - Keep the colour tokens (paper, paper-2, ink, ink-2, mute, brand). Don't restyle with hard-coded colours; rebrand by changing the token values in the CSS. - Keep the motion as it is: transform and opacity only, and the prefers-reduced-motion fallback. - Keep keyboard, focus and ARIA behaviour. - Use fake data and fake brand names in examples. Use it to: [describe where it goes and what it should do]Or use plain HTML + CSS
Not on React? Use it from Django, Rails, Laravel, Go
html/template, htmx or a static page. Loadasta.cssandasta.jsonce (thehead.htmltab), then paste the markup. Theui.astabyte.com/cdnlink is temporary: pin a version from jsDelivr for production. More in HTML + CSS.<!-- Model picker. asta.js opens it, filters on search, moves the marks and fills the hidden input. Listen for "asta:model-change". --> <div style="display:grid;gap:8px;max-width:340px"> <label id="mp-label" class="asta-label" for="mp-trigger">Default model</label> <div class="asta-model-picker" data-asta-model> <button type="button" id="mp-trigger" class="asta-model-picker-trigger" aria-haspopup="listbox" aria-expanded="false" aria-controls="mp-list" aria-labelledby="mp-label mp-trigger" data-asta-model-trigger><svg class="asta-model-picker-icon" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 1.5c.4 2.9 1.6 4.1 4.5 4.5-2.9.4-4.1 1.6-4.5 4.5-.4-2.9-1.6-4.1-4.5-4.5C6.4 5.6 7.6 4.4 8 1.5Z"/></svg><span class="asta-model-picker-value" data-asta-model-label>Astra 2</span><span class="asta-model-picker-tag" data-asta-model-tag>Default</span><svg class="asta-model-picker-chevron" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m4 6 4 4 4-4"/></svg></button> <input type="hidden" name="model" value="astra-2" data-asta-model-value> <div class="asta-model-picker-panel" hidden> <div class="asta-model-picker-search"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="7" cy="7" r="4.5"/><path d="m10.5 10.5 3 3"/></svg><input type="search" class="asta-model-picker-search-input" role="combobox" aria-expanded="true" aria-controls="mp-list" aria-autocomplete="list" aria-label="Search models" placeholder="Search models" autocomplete="off" spellcheck="false" data-asta-model-search></div> <div id="mp-list" class="asta-model-picker-list" role="listbox" aria-label="Models"><span class="asta-model-picker-mark" aria-hidden="true"></span><span class="asta-model-picker-bar" aria-hidden="true"></span> <div role="group" aria-labelledby="mp-g0"><p id="mp-g0" class="asta-model-picker-group">Astra 2</p> <div id="mp-o1" class="asta-model-picker-option" role="option" data-value="astra-2-pro" data-label="Astra 2 Pro" aria-selected="false"> <span class="asta-model-picker-main"><span class="asta-model-picker-name">Astra 2 Pro <span class="asta-model-picker-new">New</span></span><span class="asta-model-picker-hint">Deep reasoning for hard tasks</span></span> <span class="asta-model-picker-meters"><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 1.5 3.5 9H8l-1 5.5L12.5 7H8z"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span></span><span></span><span></span></span><span class="asta-sr-only">Speed 2 of 5</span></span><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.5c.3 2.2 1.3 3.2 3.5 3.5-2.2.3-3.2 1.3-3.5 3.5-.3-2.2-1.3-3.2-3.5-3.5 2.2-.3 3.2-1.3 3.5-3.5ZM12.5 10.5v3M11 12h3"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span data-on></span><span data-on></span></span><span class="asta-sr-only">Intelligence 5 of 5</span></span></span> <span class="asta-model-picker-context">1M</span> <svg class="asta-model-picker-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7"/></svg> </div> <div id="mp-o2" class="asta-model-picker-option" role="option" data-value="astra-2" data-label="Astra 2" data-tag="Default" aria-selected="true"> <span class="asta-model-picker-main"><span class="asta-model-picker-name">Astra 2</span><span class="asta-model-picker-hint">Balanced for everyday work</span></span> <span class="asta-model-picker-meters"><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 1.5 3.5 9H8l-1 5.5L12.5 7H8z"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span data-on></span><span></span></span><span class="asta-sr-only">Speed 4 of 5</span></span><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.5c.3 2.2 1.3 3.2 3.5 3.5-2.2.3-3.2 1.3-3.5 3.5-.3-2.2-1.3-3.2-3.5-3.5 2.2-.3 3.2-1.3 3.5-3.5ZM12.5 10.5v3M11 12h3"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span data-on></span><span></span></span><span class="asta-sr-only">Intelligence 4 of 5</span></span></span> <span class="asta-model-picker-context">400K</span> <svg class="asta-model-picker-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7"/></svg> </div> <div id="mp-o3" class="asta-model-picker-option" role="option" data-value="astra-2-mini" data-label="Astra 2 Mini" aria-selected="false"> <span class="asta-model-picker-main"><span class="asta-model-picker-name">Astra 2 Mini</span><span class="asta-model-picker-hint">Cheap and quick for simple steps</span></span> <span class="asta-model-picker-meters"><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 1.5 3.5 9H8l-1 5.5L12.5 7H8z"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span data-on></span><span data-on></span></span><span class="asta-sr-only">Speed 5 of 5</span></span><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.5c.3 2.2 1.3 3.2 3.5 3.5-2.2.3-3.2 1.3-3.5 3.5-.3-2.2-1.3-3.2-3.5-3.5 2.2-.3 3.2-1.3 3.5-3.5ZM12.5 10.5v3M11 12h3"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span></span><span></span></span><span class="asta-sr-only">Intelligence 3 of 5</span></span></span> <span class="asta-model-picker-context">200K</span> <svg class="asta-model-picker-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7"/></svg> </div> </div> <div role="group" aria-labelledby="mp-g1"><p id="mp-g1" class="asta-model-picker-group">Realtime</p> <div id="mp-o4" class="asta-model-picker-option" role="option" data-value="astra-fast" data-label="Astra Fast" aria-selected="false"> <span class="asta-model-picker-main"><span class="asta-model-picker-name">Astra Fast</span><span class="asta-model-picker-hint">Lowest latency for live chat</span></span> <span class="asta-model-picker-meters"><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 1.5 3.5 9H8l-1 5.5L12.5 7H8z"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span data-on></span><span data-on></span></span><span class="asta-sr-only">Speed 5 of 5</span></span><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.5c.3 2.2 1.3 3.2 3.5 3.5-2.2.3-3.2 1.3-3.5 3.5-.3-2.2-1.3-3.2-3.5-3.5 2.2-.3 3.2-1.3 3.5-3.5ZM12.5 10.5v3M11 12h3"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span></span><span></span><span></span></span><span class="asta-sr-only">Intelligence 2 of 5</span></span></span> <span class="asta-model-picker-context">32K</span> <svg class="asta-model-picker-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7"/></svg> </div> <div id="mp-o5" class="asta-model-picker-option" role="option" data-value="astra-vision" data-label="Astra Vision" aria-selected="false"> <span class="asta-model-picker-main"><span class="asta-model-picker-name">Astra Vision <span class="asta-model-picker-new">New</span></span><span class="asta-model-picker-hint">Reads screenshots and PDFs</span></span> <span class="asta-model-picker-meters"><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 1.5 3.5 9H8l-1 5.5L12.5 7H8z"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span></span><span></span></span><span class="asta-sr-only">Speed 3 of 5</span></span><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.5c.3 2.2 1.3 3.2 3.5 3.5-2.2.3-3.2 1.3-3.5 3.5-.3-2.2-1.3-3.2-3.5-3.5 2.2-.3 3.2-1.3 3.5-3.5ZM12.5 10.5v3M11 12h3"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span data-on></span><span></span></span><span class="asta-sr-only">Intelligence 4 of 5</span></span></span> <span class="asta-model-picker-context">256K</span> <svg class="asta-model-picker-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7"/></svg> </div> </div> <div role="group" aria-labelledby="mp-g2"><p id="mp-g2" class="asta-model-picker-group">Legacy</p> <div id="mp-o6" class="asta-model-picker-option" role="option" data-value="astra-1-5" data-label="Astra 1.5" aria-selected="false" aria-disabled="true"> <span class="asta-model-picker-main"><span class="asta-model-picker-name">Astra 1.5</span><span class="asta-model-picker-hint">Retired on Dec 1. Pick Astra 2.</span></span> <span class="asta-model-picker-meters"><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 1.5 3.5 9H8l-1 5.5L12.5 7H8z"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span></span><span></span></span><span class="asta-sr-only">Speed 3 of 5</span></span><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.5c.3 2.2 1.3 3.2 3.5 3.5-2.2.3-3.2 1.3-3.5 3.5-.3-2.2-1.3-3.2-3.5-3.5 2.2-.3 3.2-1.3 3.5-3.5ZM12.5 10.5v3M11 12h3"/></svg><span class="asta-model-picker-dots" aria-hidden="true"><span data-on></span><span data-on></span><span data-on></span><span></span><span></span></span><span class="asta-sr-only">Intelligence 3 of 5</span></span></span> <span class="asta-model-picker-context">128K</span> <svg class="asta-model-picker-check" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m3.5 8.5 3 3 6-7"/></svg> </div> </div> <div class="asta-model-picker-empty" data-asta-model-empty hidden><b>No models found</b><span>Nothing matches “<span data-asta-model-query></span>”. Try a family name.</span></div> </div> <div class="asta-model-picker-foot"><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 1.5 3.5 9H8l-1 5.5L12.5 7H8z"/></svg>Speed</span><span class="asta-model-picker-meter"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 2.5c.3 2.2 1.3 3.2 3.5 3.5-2.2.3-3.2 1.3-3.5 3.5-.3-2.2-1.3-3.2-3.5-3.5 2.2-.3 3.2-1.3 3.5-3.5ZM12.5 10.5v3M11 12h3"/></svg>Intelligence</span><span>↑↓ to move · Enter to pick</span></div> </div></div> <p style="font-size:12.5px;color:var(--mute)">New chats start on this model. You can switch per message.</p> </div>
Usage
The demo above, as code.
"use client";
import { useState } from "react";
import { ModelPicker, type ModelOption } from "@/components/astabyte/model-picker";
const MODELS: ModelOption[] = [
{ value: "astra-2-pro", label: "Astra 2 Pro", group: "Astra 2", tag: "Pro", hint: "Deep reasoning for hard, multi-step work", speed: 2, intelligence: 5, context: "1M", isNew: true },
{ value: "astra-2", label: "Astra 2", group: "Astra 2", tag: "Default", hint: "Balanced for everyday writing and code", speed: 4, intelligence: 4, context: "400K" },
{ value: "astra-2-mini", label: "Astra 2 Mini", group: "Astra 2", tag: "Mini", hint: "Quick answers, summaries and triage", speed: 5, intelligence: 3, context: "200K" },
{ value: "astra-fast", label: "Astra Fast", group: "Realtime", tag: "Fast", hint: "Lowest latency for voice and autocomplete", speed: 5, intelligence: 2, context: "32K" },
{ value: "astra-vision", label: "Astra Vision", group: "Realtime", tag: "Vision", hint: "Reads screenshots, charts and scans", speed: 3, intelligence: 4, context: "128K", isNew: true },
{ value: "astra-1-5", label: "Astra 1.5", group: "Legacy", tag: "1.5", hint: "Kept for older workflows", speed: 3, intelligence: 3, context: "128K", disabled: true, disabledReason: "Retired on Dec 1. Pick Astra 2." },
];
export default function ModelPickerDemo() {
const [model, setModel] = useState("astra-2");
const picked = MODELS.find((m) => m.value === model);
return (
<div className="flex min-h-[520px] w-full justify-center p-4 pt-10 sm:p-10">
<div className="flex w-full max-w-[340px] flex-col gap-2">
<span className="text-[13px] font-medium text-ink">Default model</span>
<ModelPicker models={MODELS} value={model} onChange={setModel} name="model" />
<p className="text-[12.5px] text-mute">
New chats in Astabyte start on <span className="text-ink-2">{picked?.label}</span>. Type to search, or use the arrow keys.
</p>
</div>
</div>
);
}