# Model selector

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

## Web 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.

```json
{
  "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.

```sh
npx shadcn@latest add @maeso/maeso
```

```css
@import "./styles/theme.web.css";
```

```sh
npx shadcn@latest add @maeso/model-selector
```

### Props

#### ModelSelector

| Prop | Type | Required | Description |
| --- | --- | --- | --- |
| defaultValue | string \| undefined | no |  |
| label | string \| undefined | no | The field's own name. |
| models | readonly ModelChoice[] \| undefined | no |  |
| onChange | ((id: string) => void) \| undefined | no |  |
| style | CSSProperties \| undefined | no |  |
| value | string \| undefined | no |  |

### Proof

#### Contrast

measured on 0.2.0

| State | Foreground | Background | Ratio | Floor |
| --- | --- | --- | --- | --- |
| default | rgb(67 77 86) | rgb(248 245 240) | 7.93 | AA 4.5 |
| default (dark) | rgb(181 182 182) | rgb(7 21 34) | 9.07 | AA 4.5 |

#### Keyboard

measured on 0.2.0

| Key | Action |
| --- | --- |
| Enter | Open list and commit focused model |
| Space | Open list at selected model |
| ArrowDown | Focus next model |
| ArrowUp | Focus previous model |
| Escape | Dismiss list without changing model and restore focus |
| Tab | Exit selector |
| Shift+Tab | Return to selector |

#### Size

68960 gzip bytes · measured on 0.2.0

### Example

```tsx
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;
```

### Preview · 0.2.0

not on native yet
