UI

Model selector

A model choice, named, with one line about the model currently held.

Read Markdown

Web 0.2.0

Quick answers for short turns.

  • Defaultlight7.93 : 1AA 4.5dark9.07 : 1AA 4.5
  • KeyboardEnterSpaceArrowDownArrowUpEscapeTabShift+Tab
  • measured on 0.2.0
npx shadcn@latest add @maeso/model-selector
Size
69.0 kB gzipmeasured on 0.2.0

Usage

Supply the available models and current choice. Apply a selection only when the host can use that model.

Accessibility

Label the selection and keep model names distinct. Explain unavailable choices rather than relying on dimmed text alone.

When to use

Use when the user controls model selection. Omit it when the host fixes the model.

Install

Add this registry to your project's components.json once, before the first install. Keep your existing settings and other registries.

{
  "registries": {
    "@maeso": "http://127.0.0.1:4321/r/{name}.json"
  }
}

Then install the registry's default theme once, and import its sheet in the CSS entry that imports Tailwind. It paints every item from this registry.

npx shadcn@latest add @maeso/maeso
@import "./styles/theme.web.css";
npx shadcn@latest add @maeso/model-selector

Props

ModelSelector

PropTypeRequiredDescription
defaultValuestring | undefinedno
labelstring | undefinednoThe field's own name.
modelsreadonly ModelChoice[] | undefinedno
onChange((id: string) => void) | undefinedno
styleCSSProperties | undefinedno
valuestring | undefinedno

Proof

Contrast

measured on 0.2.0

StateForegroundBackgroundRatioFloor
defaultrgb(67 77 86)rgb(248 245 240)7.93AA 4.5
default (dark)rgb(181 182 182)rgb(7 21 34)9.07AA 4.5

Keyboard

measured on 0.2.0

KeyAction
EnterOpen list and commit focused model
SpaceOpen list at selected model
ArrowDownFocus next model
ArrowUpFocus previous model
EscapeDismiss list without changing model and restore focus
TabExit selector
Shift+TabReturn to selector

Size

68960 gzip bytes · measured on 0.2.0

Example

import { ModelSelector } from "@/components/ui/_kit/chat/model-selector/ModelSelector";

const Example = () => (
		<div className="w-full max-w-105">
			<ModelSelector
				defaultValue="fast"
				models={[
					{ id: "deep", label: "Deep", detail: "Slower, deeper answers." },
					{ id: "fast", label: "Fast", detail: "Quick answers for short turns." },
				]}
			/>
		</div>
	);
export default Example;

not on native yet