SelectField
Hover decoration requires a fine pointer and hover support at widths of 768px or more. Phone and touch controls keep tap actions and keyboard focus without rollover effects.
Dropdown select on a filled container surface in small/medium/large sizes, with the same focus, hover, disabled and error states as TextInput. The dropdown list is custom-styled from theme tokens (not the native OS popup); the chevron is a Solar bold icon. For a dropdown with search/typeahead, use the radix-based Select.
Playground
Live preview
Examples
Filter select · outline without a value
Filter select · selected OpenValueActive
Searchable select inside a narrow container
Sizes
<SelectField size="small" options={options} defaultValue="apple" />
<SelectField size="medium" options={options} defaultValue="apple" />
<SelectField size="large" options={options} defaultValue="apple" />Full option names with compact selected labels
The list shows full language names; the selected trigger shows EN, ES or TR. Omit selectedLabel to keep the same label in both places.
<SelectField
size="small"
className="w-20"
listboxClassName="left-auto w-max min-w-full"
defaultValue="en"
options={[
{ value: "en", label: "English", selectedLabel: "EN" },
{ value: "es", label: "Español", selectedLabel: "ES" },
{ value: "tr", label: "Türkçe", selectedLabel: "TR" },
]}
/>With labels
import { Label, SelectField } from "@npolyhunter/ui";
<div className="space-y-2">
<Label htmlFor="fruit">Fruit</Label>
<SelectField id="fruit" options={options} placeholder="Select a fruit" />
</div>Multiple
With multiple, selecting toggles options (the list stays open) and value/onValueChange use string[]. The trigger keeps the placeholder and shows a 20×20 count badge in surface-subtle with role-guild-accent text.
// Uncontrolled
<SelectField multiple options={categories} placeholder="Categories" />
// Controlled — value is string[]
const [values, setValues] = useState<string[]>([]);
<SelectField
multiple
options={categories}
value={values}
onValueChange={setValues}
placeholder="Categories"
/>
// Options also accept { id, label } — ids are used as the values
const categories = [
{ id: "weapons", label: "Weapons" },
{ id: "armor", label: "Armor" },
];With id/label options
Options can carry id instead of value — the id is what gets emitted in value/onValueChange, so you can pass database rows straight through:
// Options accept { id, label } — pass rows straight from your API
const weapons = [
{ id: "sword", label: "Sword" },
{ id: "bow", label: "Bow" },
];
<SelectField options={weapons} placeholder="Weapon" />
<SelectField multiple options={weapons} placeholder="Loadout" />With leading icon
Pass any node to icon to render it at the start of the trigger — sized 20px, colors inherited from the trigger (placeholder tint when nothing is selected).
import { SelectField } from "@npolyhunter/ui";
import { FilterBoldDuotoneIcon } from "@npolyhunter/ui/icons";
// Leading icon — colors inherit from the trigger (no overrides)
<SelectField
icon={<FilterBoldDuotoneIcon />}
multiple
options={categories}
placeholder="Categories"
/>Long option labels — wider dropdown
The dropdown grows beyond the narrow Work stage trigger to fit its options. It stays inside the viewport and wraps only when the available popup width is exhausted.
States
Focus switches to a 2px focus-neutral border. Invalid uses status-danger-border for the border and a danger-tinted ring, and on focus becomes 2px status-danger-foreground. Disabled keeps the container surface with a subtle border and disabled text. Readonly shows the value but never opens the dropdown and suppresses the focus treatment. The selected option shows the shared CheckIcon in icon-foreground; disabled options are skipped by keyboard navigation.
<SelectField options={options} defaultValue="apple" />
<SelectField options={options} disabled defaultValue="apple" />
// Readonly — value shown at full foreground color, no dropdown opens,
// and the focus border treatment is suppressed
<SelectField options={options} readOnly defaultValue="apple" />
<SelectField options={options} readOnly placeholder="Readonly placeholder" />
// Error — border uses status-danger-border; on focus it becomes 2px status-danger-foreground
<SelectField options={options} invalid defaultValue="apple" />
// Disabled option
const options = [
{ value: "durian", label: "Durian", disabled: true },
];Category descriptions
Optional supporting text stays below each complete option label. The selected trigger shows only the label. Search matches either line.
<SelectField options={[{ value: "research", label: "Research", description: "Compare sources and provide evidence." }]} />Code
import { SelectField, type SelectFieldOption } from "@npolyhunter/ui";
const options: SelectFieldOption[] = [
{ value: "apple", label: "Apple" },
{ value: "banana", label: "Banana" },
];
// Default (filled container surface, custom styled dropdown)
<SelectField options={options} placeholder="Select a fruit" />
// Sizes small / medium / large
<SelectField size="small" options={options} />
<SelectField size="medium" options={options} />
<SelectField size="large" options={options} />
// Filter variants: selected values use the brand and success border
<SelectField variant="outline" options={options} placeholder="Any fruit" />
<SelectField variant="openValueActive" options={options} value="apple" />
// Controlled
<SelectField
options={options}
value={value}
onValueChange={setValue}
placeholder="Select a fruit"
/>
// Multiple — string[] value, count badge next to the placeholder
<SelectField
multiple
options={options}
value={values}
onValueChange={setValues}
placeholder="Categories"
/>
// Error / disabled
<SelectField invalid options={options} />
<SelectField disabled options={options} />Code
<SelectField
size="${size}" // "small" | "medium" | "large"
options={options}
value={value} // string
onValueChange={setValue}
placeholder="Select a fruit"
invalid={${invalid}}
disabled={${disabled}}
/>Used in
Includes use through shared UI components.
