Loading component…
Loading component…
Pick one option in the Text Field's look
To reuse this local React demo, copy all files from the Code tab into the same folder, then import Select from ./select.
import { useState } from "react";
import { Select, type SelectOption } from "@/components/ui/select";
const models: SelectOption[] = [
{ value: "auto", label: "Auto", description: "Picks the model for each message" },
{ value: "opus", label: "Claude Opus 5.5", description: "Best for hard, long questions" },
{ value: "custom", label: "Your own model", description: "Add an endpoint first", disabled: true },
];
export function ModelSetting() {
const [model, setModel] = useState<string | null>("auto");
return <Select label="Default model" options={models} value={model} onChange={setModel} name="model" />;
}| Name | Type | Default | Description |
|---|---|---|---|
| options | SelectOption[] | { value, label, description?, icon?, disabled? } – an icon and a quiet second line are optional per option | |
| value | string \| null | The chosen value – makes it controlled; null shows the placeholder | |
| defaultValue | string \| null | null | Starting value when uncontrolled |
| onChange | (value: string, option: SelectOption) => void | Called when another option is picked | |
| placeholder | string | "Choose…" | Shown in gray while nothing is chosen |
| label | ReactNode | Shown above the field and used as the list's name | |
| hint | ReactNode | A quiet line under the field – the error takes its place while there is one | |
| error | ReactNode | Marks the field invalid (red edge and a faint red fill, aria-invalid) and shows the message where the hint was | |
| optional | boolean | false | Adds "Optional" next to the label |
| size | "sm" \| "md" \| "lg" | "md" | 32 · 36 · 40px high, like the Text Field; taller on touch screens |
| disabled | boolean | false | Dims the field and ignores input |
| name | string | Sends the value with a form, through a hidden input | |
| required | boolean | Sets aria-required – check it on submit like any other field | |
| aria-label | string | Accessible name when there is no visible label | |
| className | string | Extra class on the wrapper, e.g. a fixed width in a settings row | |
| ref | Ref<HTMLButtonElement> | The field's button – focus it after a validation error |
Fills its container; a long choice ends in … with the full text on hover
The list opens where there is room – under the field, or above it near the bottom of the screen – and stays inside the window
It lives in the top layer (popover), so a card's overflow or z-index never cuts it
Touch screens get taller rows and 16px text; dark mode built in via .dark or data-theme="dark" on an ancestor
@import "tailwindcss"; in your main CSS file.