Select
A single-select dropdown — data-driven, searchable, accessible, in React (@bpdm/ui) and Angular (@bpdm/ng).
The Select is a single-choice dropdown. It's data-driven — you pass an
options array (flat or grouped) rather than markup — with optional search,
controlled or uncontrolled value, and long lists virtualized for performance.
Usage
import { Select } from '@bpdm/ui/select';
const FRAMEWORKS = [
{ value: 'react', label: 'React' },
{ value: 'angular', label: 'Angular' },
{ value: 'vue', label: 'Vue' },
{ value: 'svelte', label: 'Svelte' },
];
export function SelectUsage() {
return <Select options={FRAMEWORKS} placeholder="Select a framework" />;
}Searchable
Set searchable to add a filter box — handy for long lists. Customise the empty
state with emptyText and the field with searchPlaceholder.
import { Select } from '@bpdm/ui/select';
export function SelectSearchable({ frameworks }) {
return <Select searchable options={frameworks} placeholder="Search frameworks" />;
}With icons
Each option (and group) accepts an icon — rendered before the label in both
the trigger and the dropdown.
import { Circle, CircleDashed, CircleCheck, CircleX } from 'lucide-react';
import { Select } from '@bpdm/ui/select';
const STATUSES = [
{ value: 'todo', label: 'Todo', icon: <Circle className="size-4 text-muted-foreground" /> },
{ value: 'in-progress', label: 'In progress', icon: <CircleDashed className="size-4 text-primary" /> },
{ value: 'done', label: 'Done', icon: <CircleCheck className="size-4 text-primary" /> },
{ value: 'canceled', label: 'Canceled', icon: <CircleX className="size-4 text-destructive" /> },
];
export function SelectWithIcons() {
return <Select options={STATUSES} placeholder="Set status" />;
}Grouped options
Pass groups ({ label, options }) instead of flat options to show labelled
sections. The group label can include an emoji or icon.
import { Select } from '@bpdm/ui/select';
const CITIES = [
{
label: '🇩🇪 Germany',
options: [
{ value: 'berlin', label: 'Berlin' },
{ value: 'frankfurt', label: 'Frankfurt' },
{ value: 'hamburg', label: 'Hamburg' },
{ value: 'munich', label: 'Munich' },
],
},
{
label: '🇺🇸 USA',
options: [
{ value: 'nyc', label: 'New York' },
{ value: 'la', label: 'Los Angeles' },
{ value: 'chicago', label: 'Chicago' },
],
},
];
export function SelectGroups() {
return <Select options={CITIES} placeholder="Select a city" />;
}Large datasets
The dropdown is virtualized — only the visible rows render — so it stays smooth even with thousands of options. Open it and scroll through 10,000 rows.
import { Select } from '@bpdm/ui/select';
const options = Array.from({ length: 10000 }, (_, i) => ({
value: `item-${i}`,
label: `Item ${i + 1}`,
}));
export function SelectLarge() {
return <Select options={options} placeholder="Scroll 10,000 records" />;
}Sizes
The size prop offers sm, md (default), and lg.
import { Select } from '@bpdm/ui/select';
const frameworks = [
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'angular', label: 'Angular' },
];
export function Sizes() {
return (
<div className="flex flex-col gap-3">
<Select size="sm" options={frameworks} placeholder="Small" />
<Select size="md" options={frameworks} placeholder="Medium" />
<Select size="lg" options={frameworks} placeholder="Large" />
</div>
);
}States
Set a defaultValue, mark the field with aria-invalid for errors, or
disabled to turn it off.
import { Select } from '@bpdm/ui/select';
const frameworks = [
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'angular', label: 'Angular' },
];
export function States() {
return (
<div className="flex flex-col gap-3">
<Select options={frameworks} placeholder="Default" />
<Select options={frameworks} defaultValue="react" />
<Select options={frameworks} aria-invalid placeholder="Invalid" />
<Select options={frameworks} disabled placeholder="Disabled" />
</div>
);
}Controlled value
Drive the selection yourself with value + onValueChange (React) or two-way
[(value)] (Angular).
import { useState } from 'react';
import { Select } from '@bpdm/ui/select';
const frameworks = [
{ value: 'react', label: 'React' },
{ value: 'vue', label: 'Vue' },
{ value: 'angular', label: 'Angular' },
];
export function SelectControlled() {
const [value, setValue] = useState('react');
return <Select options={frameworks} value={value} onValueChange={setValue} />;
}Per-slot styling
className (or Angular class) styles the trigger as a whole. To restyle individual
parts without reaching into the internal data-bpdm-slot elements from CSS, pass a
classNames object — one key per slot: trigger, value, content, search, empty,
list, group and option. Each entry merges with the component's own classes, so you
override only what you name.
import { Select } from '@bpdm/ui/select';
const CITIES = [
{
label: '🇩🇪 Germany',
options: [
{ value: 'berlin', label: 'Berlin' },
{ value: 'frankfurt', label: 'Frankfurt' },
{ value: 'hamburg', label: 'Hamburg' },
{ value: 'munich', label: 'Munich' },
],
},
{
label: '🇺🇸 USA',
options: [
{ value: 'nyc', label: 'New York' },
{ value: 'la', label: 'Los Angeles' },
{ value: 'chicago', label: 'Chicago' },
],
},
];
export function BrandedSelect() {
return (
<Select
searchable
options={CITIES}
defaultValue="berlin"
placeholder="Select a city"
classNames={{
trigger: 'rounded-xl border-2',
value: 'font-mono uppercase tracking-wide',
content: 'rounded-xl',
search: 'bg-muted',
group: 'uppercase tracking-wide text-primary',
option: 'rounded-md',
}}
/>
);
}API
| Prop | Type | Default | Description |
|---|---|---|---|
options | SelectItems (flat { value, label, icon?, disabled? }[] or grouped { label, icon?, options }[]) | — | Required. Data-driven options; each option/group may carry an icon. |
value / defaultValue | string | — | Controlled / uncontrolled selection. |
onValueChange | (value: string) => void | — | React — fires on selection. Angular uses two-way [(value)] or binds via formControlName / [(ngModel)] (see Forms). |
placeholder | string | Select… | Text when nothing is selected. |
searchable | boolean | false | Show a filter box. |
searchPlaceholder | string | Search… | Placeholder for the filter box. |
emptyText | string | No results. | Shown when the filter matches nothing. |
size | sm | md | lg | md | Trigger height and text size. |
disabled | boolean | false | Disable the control. |
aria-invalid | boolean | — | Error state (destructive border). |
id | string | — | Trigger id (for <label> association / testing). |
aria-label / aria-describedby | string | — | Accessible name / description for the trigger + option list. |
classNames | SelectClassNames | — | Per-slot class overrides: { trigger, value, content, search, empty, list, group, option }. Each merges with the component's own classes. |
maxHeight (px) caps the scrollable list. In React, contentClassName styles the dropdown
panel. Both frameworks accept aria-label / aria-describedby (forwarded to the trigger and used
to name the listbox).
SelectClassNames: { trigger, value, content, search, empty, list, group, option }.
Forms
There's no ControlValueAccessor in React — the component is fully controlled through
value + onValueChange, so it drops into any form library. With react-hook-form, wrap
it in a <Controller>:
<Controller
name="fruit"
control={control}
render={({ field }) => (
<Select options={fruits} value={field.value} onValueChange={field.onChange} />
)}
/>Accessibility
- Full WAI-ARIA combobox + listbox wiring: the trigger is
role="combobox"witharia-haspopup="listbox",aria-expanded, andaria-controlspointing at therole="listbox"panel; options arerole="option"witharia-selected. - The highlighted option is exposed via
aria-activedescendanton the focused element (the search box whensearchable, otherwise the listbox), so screen readers announce each option as you arrow through — even though the list is virtualized. Group headers are decorative (aria-hidden). - Keyboard: ↑/↓ move the active option, Home/End
jump to the first/last option, Enter selects, and Esc closes. Type-ahead:
when not
searchable, typing printable characters focuses the first option starting with what you typed (rapid keystrokes accumulate). Withsearchable, the filter is an editable combobox (aria-autocomplete="list") and typing filters instead. - The active/highlighted option is marked with an amber inline-start bar plus a soft tint and heavier text — a clearly perceptible ≥3:1 focus indicator (not colour alone), mirrored under RTL.
- Truncated text (a long selected value or option label) carries a native
title, so the full text is revealed on hover. - Give it a name — pair a
<label>(linked viaid) or passaria-label. Setaria-invalidwhen selection fails validation.
Internationalization
- All built-in copy is translatable via props:
placeholder,searchPlaceholder, andemptyText— pass your localized strings (there's no hard-coded catalogue). Option/grouplabels are your data, already translated. Give the field a translatedaria-label. - RTL-safe: options use logical alignment (
text-start) and the trigger lays out withjustify-between, so the chevron, checkmark, and text mirror underdir="rtl". See the Internationalization guide.