Form

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

select-usage.tsx
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.

select-searchable.tsx
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.

select-icons.tsx
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.

select-groups.tsx
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.

select-large.tsx
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.

select-sizes.tsx
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.

select-states.tsx
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).

select-controlled.tsx
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.

select-slots.tsx
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

PropTypeDefaultDescription
optionsSelectItems (flat { value, label, icon?, disabled? }[] or grouped { label, icon?, options }[])—Required. Data-driven options; each option/group may carry an icon.
value / defaultValuestring—Controlled / uncontrolled selection.
onValueChange(value: string) => void—React — fires on selection. Angular uses two-way [(value)] or binds via formControlName / [(ngModel)] (see Forms).
placeholderstringSelect…Text when nothing is selected.
searchablebooleanfalseShow a filter box.
searchPlaceholderstringSearch…Placeholder for the filter box.
emptyTextstringNo results.Shown when the filter matches nothing.
sizesm | md | lgmdTrigger height and text size.
disabledbooleanfalseDisable the control.
aria-invalidboolean—Error state (destructive border).
idstring—Trigger id (for <label> association / testing).
aria-label / aria-describedbystring—Accessible name / description for the trigger + option list.
classNamesSelectClassNames—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>:

react-hook-form
<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" with aria-haspopup="listbox", aria-expanded, and aria-controls pointing at the role="listbox" panel; options are role="option" with aria-selected.
  • The highlighted option is exposed via aria-activedescendant on the focused element (the search box when searchable, 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). With searchable, 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 via id) or pass aria-label. Set aria-invalid when selection fails validation.

Internationalization

  • All built-in copy is translatable via props: placeholder, searchPlaceholder, and emptyText — pass your localized strings (there's no hard-coded catalogue). Option/group labels are your data, already translated. Give the field a translated aria-label.
  • RTL-safe: options use logical alignment (text-start) and the trigger lays out with justify-between, so the chevron, checkmark, and text mirror under dir="rtl". See the Internationalization guide.

On this page