Select Dropdown

Free

Single, multi-select, grouped and searchable dropdown with rich option rendering.

</>sv-select-dropdown selectdropdownform
import { SvSelectDropdownComponent } from '@styloviz/select-dropdown';

Demo & usage

Basic usage

Usage example — open the gallery for the full interactive demo.

An interactive demo for this component lives in the gallery.

Open live demo

More examples

Bottom sheet on phones

`sheetOnNarrow` (both tiers): below 640px the panel opens as a full-width bottom sheet — clear of the home indicator and of the virtual keyboard the search box raises, and re-anchored rather than closed when that keyboard resizes the viewport. The kit's shared `createSheetMode` contract; off by default.

example.htmlAngular
<sv-select-dropdown [options]="options" [sheetOnNarrow]="true" [(value)]="value" />

Create a new option (Pro)

On `sv-select-dropdown-pro` with a search box: `creatable` adds a Create row when the search matches no option label; `createRequest` hands the host a typed request to persist, and `awaitCreate` keeps the option pending (italic, busy) in the trigger until `resolve()` — with the server id — selects it.

example.htmlAngular
<sv-select-dropdown-pro [options]="teams()" [creatable]="true" [awaitCreate]="true"
  [(value)]="team" (createRequest)="save($event)">
  <ng-container svSelectSearch />
</sv-select-dropdown-pro>

Grouped options

Pass groups for sectioned, labelled lists.

example.htmlAngular
<sv-select-dropdown
  [groups]="frameworkGroups"
  placeholder="Pick a stack"
  [(value)]="stack"
  (selectionChange)="onChange($event)" />

Compact, filled

example.htmlAngular
<sv-select-dropdown [options]="options" size="sm" variant="filled" [(value)]="value" />

Searchable with remote filtering

svSelectSearch emits searchChange on every (debounced) query, so a host can fetch matches itself; serverSide stops the select filtering what the server already filtered. Customise the empty/search copy on the same child.

example.htmlAngular
<sv-select-dropdown [options]="results" [clearable]="true" [(value)]="userId">
  <ng-container
    svSelectSearch
    [serverSide]="true"
    searchPlaceholder="Search users…"
    noResultsText="No users match"
    (searchChange)="onSearch($event)" />
</sv-select-dropdown>

Server search, without wiring it yourself

Hand it the endpoint instead of the results. The debounce, the request guard, the abort, the loading/stale split and the retry come with it — the guard being the part everyone skips, and skipping it is what makes a picker show suggestions for the term before last.

example.htmlAngular
<sv-select-dropdown [source]="people" [selectedOption]="current()" [(value)]="personId">
  <ng-container svSelectSearch [minChars]="2" />
</sv-select-dropdown>

<!-- people = svSelectSource<SelectOption>({
       search: (term, signal) =>
         fetch(`/api/people?q=${encodeURIComponent(term)}`, { signal }).then((r) => r.json()),
     });

     Pass selectedOption too: a fetched list is whatever answers the
     current term, so a perfectly valid selection is routinely not in
     it — and without the hydration input the trigger calls it stale. -->

Composed: features as children, options from an adapter

Features are content children that render nothing and register through a token; where the options come from is one adapter, svSelectSource from @styloviz/core, which owns search, paging and the loading / stale / error states. Each setting resolves as source, then feature child, then the select's built-in default.

example.htmlAngular
<sv-select-dropdown [source]="people" [selectedOption]="current()" [(value)]="personId">
  <ng-container svSelectSearch searchPlaceholder="Search people…" />
</sv-select-dropdown>

<!-- Pro adds windowing and bulk selection the same way: -->
<sv-select-dropdown-pro [options]="rows()" [multiple]="true" [maxSelected]="10" [(value)]="ids">
  <ng-container svSelectSearch />
  <ng-container svSelectVirtual [optionHeight]="52" />
  <ng-container svSelectBulk selectAllLabel="Add everyone" />
</sv-select-dropdown-pro>

<!-- people = svSelectSource<SelectOption>({
       search: (term, signal, { offset, limit }) => api.people(term, offset, limit, signal),
       pageSize: 50,   // rows per "Load more"; 0 = whole answer per term
       minChars: 2,
     }); -->

Signal Forms

Bind it with `[formField]` from `@angular/forms/signals` — the control is a ControlValueAccessor, which Signal Forms drives on Angular 21 and 22 alike.

select-dropdown.signal-forms.tsTypeScript
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { FormField, form, required } from '@angular/forms/signals';
import { SvSelectDropdownComponent, type SelectOption } from '@styloviz/select-dropdown';

@Component({
  selector: 'app-select-dropdown-signal-forms',
  standalone: true,
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [FormField, SvSelectDropdownComponent],
  template: `
    <sv-select-dropdown [formField]="workspace.plan" [options]="plans" label="Plan" />
    <p>Plan: {{ workspace.plan().value() }} · valid: {{ workspace.plan().valid() }}</p>
  `,
})
export class SelectDropdownSignalFormsExample {
  readonly plans: readonly SelectOption[] = [
    { value: 'starter', label: 'Starter' },
    { value: 'growth', label: 'Growth' },
    { value: 'enterprise', label: 'Enterprise' },
  ];
  readonly model = signal({ plan: '' });
  readonly workspace = form(this.model, (path) => {
    required(path.plan);
  });
}

When to use

  • Choosing one (or a few) options from a known, moderate-length list.
  • You want search, grouping or rich option rendering beyond a native <select>.
  • For free-text entry with suggestions use Autocomplete; for many tags use Tag Input.

Compare with

  • Audio Device Select — Audio Device Select is a Select Dropdown filled from the browser's microphones and speakers, with the permission states and a level meter.

Async states

  • loading

Inputs

NameTypeDefaultDescription
valuestring | string[] (two-way)''Selected value(s) — string for single, string[] for multiple (two-way).
optionsreadonly SelectOption[][]Flat list of options. Use `groups` instead for sectioned lists.
groupsSelectGroup[][]Grouped options with section labels.
placeholderstring'Select an option'Placeholder shown when nothing is selected.
labelstring''Field label.
hintstring''Helper text shown below the field.
errorMessagestring''Error message; puts the field in an error state when set.
serverErrorstring | { readonly message: string } | nullnullA validation failure reported by the **server** — the 422 that comes back after submit, not something the client could have known. It is a separate input from `errorMessage` because it has a different lifetime, not because it needs a second way to show a string. A server error is a statement about *the value that was submitted*: the moment the user edits the field it stops being true, and this input expires itself rather than sitting there telling someone their new email is already taken. `errorMessage` has no such expiry — it is the host's to clear. While live it outranks `errorMessage`: it is the more specific fact, and it is the one the user has not seen yet. Typed structurally rather than as `SvDataError` so this stays dependency free — an `SvDataError` satisfies it unchanged.
sizeSelectSize'md'Field size: sm, md or lg.
variantSelectVariant'default'Visual variant.
multiplebooleanfalseAllow selecting multiple options.
clearablebooleanfalseShow a clear (×) control.
disabledbooleanfalseDisable the field.
loadingbooleanfalseThe host is still resolving the *selected* value — fetching the entity a saved id points at, say. The trigger shows a spinner, reports `aria-busy` and does not open, so a user cannot pick against a value that is about to change under them. The option list's own loading state comes from `source` (`svSelectSource` from `@styloviz/core`); the two are OR-ed in the panel.
requiredbooleanfalseMark the field as required.
optionalTagbooleanfalseShow an "optional" tag next to the label.
maxSelectednumber0Max selectable options in multiple mode (0 = unlimited).
inputIdstring''Explicit id for the control (for external <label for>).
ariaLabelstring''Accessible name for the trigger when there is no visible `label`. Use this instead of a native `aria-label` on the host element (which is not a labelable role and would be an ARIA violation). Falls back to the `placeholder` so the combobox always has an accessible name.
customClassstring''Extra CSS classes for the control.
selectedOptionSelectOption | nullnullThe option matching the current `value`, for when its label lives on the server and is not in `options` yet. Without it a picker restored from a saved id shows the raw id until the user opens the panel.
sheetOnNarrowbooleanfalseBelow 640px, open the panel as a bottom sheet — full width, clear of the home indicator and of the virtual keyboard the search box raises — instead of anchoring it to the trigger, where a phone has no room beside it. The kit's shared contract (`createSheetMode`, as `sv-dropdown-menu`). Off by default, so an existing app does not change on a phone.
sourceSvSelectSource<SelectOption> | nullnullWhere the options come from — search, paging and async state as one object. Build it with `svSelectSource({ search, pageSize, minChars, debounceMs })` from `@styloviz/core`. With a source set the component fetches on open, searches as the user types, appends pages on "Load more" and retries a failure itself — no host handler is involved.

Outputs

EventPayload typeDescription
selectionChangestring | string[]Emitted with the new selection (string or string[]).
dropdownOpenvoidEmitted when the dropdown opens.
dropdownClosevoidEmitted when the dropdown closes.
valueChangestring | string[]Emits the new `value` whenever it changes — the output half of `[(value)]`.

<sv-select-dropdown-pro>

Also in this family — SvSelectDropdownProComponent from @styloviz-pro/select-dropdown.

Async states

  • loading

Inputs

NameTypeDefaultDescription
valuestring | string[] (two-way)''Selected value(s) — string for single, string[] for multiple (two-way).
optionsreadonly SelectOption[][]Flat list of options. Use `groups` instead for sectioned lists.
groupsSelectGroup[][]Grouped options with section labels.
placeholderstring'Select an option'Placeholder shown when nothing is selected.
labelstring''Field label.
hintstring''Helper text shown below the field.
errorMessagestring''Error message; puts the field in an error state when set.
serverErrorstring | { readonly message: string } | nullnullA validation failure reported by the **server** — the 422 that comes back after submit, not something the client could have known. It is a separate input from `errorMessage` because it has a different lifetime, not because it needs a second way to show a string. A server error is a statement about *the value that was submitted*: the moment the user edits the field it stops being true, and this input expires itself rather than sitting there telling someone their new email is already taken. `errorMessage` has no such expiry — it is the host's to clear. While live it outranks `errorMessage`: it is the more specific fact, and it is the one the user has not seen yet. Typed structurally rather than as `SvDataError` so this stays dependency free — an `SvDataError` satisfies it unchanged.
sizeSelectSize'md'Field size: sm, md or lg.
variantSelectVariant'default'Visual variant.
multiplebooleanfalseAllow selecting multiple options.
clearablebooleanfalseShow a clear (×) control.
disabledbooleanfalseDisable the field.
loadingbooleanfalseThe host is still resolving the *selected* value — fetching the entity a saved id points at, say. The trigger shows a spinner, reports `aria-busy` and does not open, so a user cannot pick against a value that is about to change under them. The option list's own loading state comes from `source` (`svSelectSource` from `@styloviz/core`); the two are OR-ed in the panel.
requiredbooleanfalseMark the field as required.
optionalTagbooleanfalseShow an "optional" tag next to the label.
maxSelectednumber0Max selectable options in multiple mode (0 = unlimited).
inputIdstring''Explicit id for the control (for external <label for>).
ariaLabelstring''Accessible name for the trigger when there is no visible `label`. Use this instead of a native `aria-label` on the host element (which is not a labelable role and would be an ARIA violation). Falls back to the `placeholder` so the combobox always has an accessible name. Mirrors the free `sv-select-dropdown` input deliberately: an upgrade free→Pro must not drop an accessibility API and fail with NG8002.
customClassstring''Extra CSS classes for the control.
selectedOptionSelectOption | nullnullThe option matching the current `value`, for when its label lives on the server and is not in `options` yet. Without it a picker restored from a saved id shows the raw id until the user opens the panel.
creatablebooleanfalseOffer an explicit "Create ‹search›" row when the search text matches no option's label. Needs a search box (`svSelectSearch`); activating the row emits `createRequest`.
awaitCreatebooleanfalseKeep a created option PENDING — shown in the trigger, marked busy, not yet selected — until the host settles `createRequest`. Off, the option is selected at once and `reject()` takes it back out.
sheetOnNarrowbooleanfalseBelow 640px, open the panel as a bottom sheet — full width, clear of the home indicator and of the virtual keyboard the search box raises — instead of anchoring it to the trigger, where a phone has no room beside it. The kit's shared contract (`createSheetMode`, as `sv-dropdown-menu`). Off by default, so an existing app does not change on a phone.
sourceSvSelectSource<SelectOption> | nullnullWhere the options come from — search, paging and async state as one object. Build it with `svSelectSource({ search, pageSize, minChars, debounceMs })` from `@styloviz/core`. With a source set the component fetches on open, searches as the user types, appends pages on "Load more" and retries a failure itself — no host handler is involved.

Outputs

EventPayload typeDescription
selectionChangestring | string[]Emitted with the new selection (string or string[]).
dropdownOpenvoidEmitted when the dropdown opens.
dropdownClosevoidEmitted when the dropdown closes.
createRequestSvCreateRequestThe user activated "Create ‹search›": persist it, then `resolve()` (with the server's id) or `reject()`. Shared with sv-autocomplete and sv-tag-input-pro.
valueChangestring | string[]Emits the new `value` whenever it changes — the output half of `[(value)]`.

Customization & theming

  • Pass `options` (and `groups`) for grouped lists; each option supports `icon` (an icon-library name), `avatarUrl`, `sublabel`, `badge` / `badgeColor` and `disabled`.
  • Toggle `multiple` and `clearable`; cap multi-select with `maxSelected` and size/style via `size` and `variant` (default · filled · flushed · floating).
  • Search is a content child: `<ng-container svSelectSearch />` turns it on, and it carries `searchPlaceholder`, `noResultsText`, `loadingText`, `minChars`, `debounceMs`, `serverSide` and `(searchChange)`. A member it leaves unbound keeps the select's default.
  • Pro: long flat lists window themselves above 150 rows; `<ng-container svSelectVirtual />` overrides `virtualThreshold`, `optionHeight` and `virtualViewportHeight`. Grouped lists are never windowed — headers and options are two different index spaces, and half-doing it would navigate wrongly.
  • Pro: `<ng-container svSelectBulk />` adds a tri-state "select all" to a multi-select (`selectAllLabel` for the wording). It acts on the VISIBLE, ENABLED options — not the whole array — deselects only what is on screen, and refuses (rather than filling up to) a `maxSelected` cap.
  • A server list is `[source]="svSelectSource({ search, pageSize, minChars, debounceMs })"` from `@styloviz/core`: it fetches on open, searches as the user types, pages on "Load more", retries a failure itself and owns the loading / stale / error states. A list it fetched is never filtered again. Closing aborts what is in flight but keeps what is on screen, so a live selection does not read as "Unavailable" the moment the panel shuts. Pass `selectedOption` for a value its list may not contain.
  • `loading` is the host's own switch for the trigger: set it while you resolve the selected entity, and the trigger spins, reports `aria-busy` and does not open.
  • Drive validation with `required`, `errorMessage`, `serverError` and `hint`; react to `selectionChange` and `dropdownOpen` / `dropdownClose`. Free ships only `svSelectSearch`; the Pro directives share its token and are ignored by the free select.

Forms integration

  • sv-select-dropdown — ControlValueAccessor.[formControl], formControlName, [(ngModel)] and Signal Forms [formField] all work.
  • sv-select-dropdown-pro — ControlValueAccessor.[formControl], formControlName, [(ngModel)] and Signal Forms [formField] all work.

Best practices

  • Do: Enable search once the list passes ~8 options so users can type to filter.
  • Do: Group long lists with `groups` and concise section labels.
  • Don't: Avoid using a dropdown for 2–3 mutually exclusive choices — a Segmented Control or Radio Group is clearer.
  • Tip: Provide a sensible `placeholder` describing the choice, not just "Select…".
  • Do: Decide what happens when a selected value leaves the option list. The control does not fall back to the placeholder for it — "Select an option" while the form still holds a value would read as empty, and the user would submit something they believed they never chose. It reads `Unavailable (<id>)`, and `hasStaleValue()` / `staleValues()` let you react.
  • Don't: Don't confuse a stale value with a hydrating one. `selectedOption` supplies the label for a value restored from a server before its list has loaded — that is "not yet", and it is not stale. "Not any more" is a value the list has actively dropped.
  • Do: Prefer `[source]="svSelectSource({ search })"` over wiring `svSelectSearch (searchChange)` yourself once the list comes from a server. The hand-rolled version needs a request guard so a slow answer to an abandoned term cannot overwrite a newer one, and that is the piece that gets left out — it looks correct in review and only misbehaves under latency you do not have locally. The source also pages (`pageSize`), so "Load more" needs no host code either.

Accessibility

  • Full ARIA combobox: `role="combobox"` with `aria-expanded`, `aria-haspopup`, `aria-controls` and `aria-activedescendant`; the popup is a `role="listbox"` of `role="option"` rows with stable ids.
  • Keyboard: arrows, Home/End to move, Enter to select, Esc/Tab to close — the active option is scrolled into view and announced to screen readers.
  • Pro, windowed lists: the active option is always kept mounted. `aria-activedescendant` names it by DOM id, and a window that unmounted it would leave that id dangling — the screen reader then announces nothing at all as the user arrows. The spacer rows are `aria-hidden` so a windowed listbox does not report two unreachable phantom items.
  • A unique id is generated automatically so the `<label>` association, `aria-labelledby` and `aria-describedby` (hint/error) always resolve, even without `inputId`.
  • Closes on outside click and returns focus to the trigger; programmatic `formControl.disable()` disables the native trigger.

Feedback on Select Dropdown

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.