Search a list of options and choose one or several values.

Use a Combobox when people need to find a choice by typing. Start with an input and a list, then add chips, server results, or the option to create something new as you need them.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container uiCombobox>
      <div data-slot="stack">
        <label uiComboboxLabel>Framework</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Select a framework" />
          <button uiComboboxTrigger aria-label="Show frameworks">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No frameworks found.</div>
        <div uiComboboxList>
          @for (framework of frameworks; track framework.value) {
            <div
              uiComboboxItem
              [value]="framework.value"
              [label]="framework.label"
            >
              {{ framework.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly frameworks = [
    { value: "next", label: "Next.js" },
    { value: "sveltekit", label: "SvelteKit" },
    { value: "nuxt", label: "Nuxt" },
    { value: "remix", label: "Remix" },
    { value: "astro", label: "Astro" },
    { value: "solidstart", label: "SolidStart" },
    { value: "qwik", label: "Qwik City" },
  ]
}

export { Example }
Type “sv” to find SvelteKit. Press Down Arrow to highlight it, then Enter to choose it.

Installation

npm install @ui-sdk/angular @ui-sdk/core

Composition

Use the following composition to build Combobox:

uiCombobox
├── uiComboboxLabel
├── uiComboboxInput
└── uiComboboxContent
    └── uiComboboxList
        ├── uiComboboxItem
        └── uiComboboxItem

Name the input, give each option a unique value, and put the options in a list inside the popup. The label names the input; choosing an option puts its label in the input.

Usage

Import the parts and put them together:

import { Component } from "@angular/core"
import {
  Combobox,
  ComboboxContent,
  ComboboxInput,
  ComboboxItem,
  ComboboxLabel,
  ComboboxList,
} from "@ui-sdk/angular/combobox"

@Component({
  selector: "app-example",
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxInput,
    ComboboxItem,
    ComboboxLabel,
    ComboboxList,
  ],
  template: `
    <ng-container uiCombobox>
      <label uiComboboxLabel>Fruit</label>
      <input uiComboboxInput placeholder="Search fruits…" />
      <div *uiComboboxContent>
        <div uiComboboxList>
          <div uiComboboxItem value="apple">Apple</div>
          <div uiComboboxItem value="banana">Banana</div>
        </div>
      </div>
    </ng-container>
  `,
})
class Example {}

export { Example }

Autocomplete vs Combobox

Both filter a list as you type. They differ in what the value is.

  • Combobox: the value is an option from the list, or several with multiple. The text is only a query; closing without choosing restores the selected label, and a form submits the value, not the text. Use it for a country, an assignee or a set of labels.
  • Autocomplete: the value is the text. Suggestions help fill it in, and anything typed is valid. Use it for a search box, an address or a free-form field.

allowCustomValue lets a combobox accept text that matches no option, like a datalist. Reach for it when choosing from the list is the main path; use an autocomplete when free text is.

Build Your Own

@ui-sdk/angular/combobox comes with a ready-made Combobox. If you'd like to build your own, with your own names, start from the combobox primitive in @ui-sdk/core:

country-picker.ts
import { Directive, inject, input, type InputSignal } from "@angular/core"
import { combobox, type ComboboxItemProps } from "@ui-sdk/core/combobox"
import { usePart, usePrimitive } from "@ui-sdk/angular/primitive"

@Directive({ selector: "[appCountryPicker]" })
class CountryPicker {
  readonly handle = usePrimitive(combobox, () => ({}))
}

@Directive({ selector: "[appCountryLabel]" })
class CountryLabel {
  readonly state = usePart(inject(CountryPicker).handle, "label").state
}

@Directive({ selector: "[appCountryInput]" })
class CountryInput {
  readonly state = usePart(inject(CountryPicker).handle, "input").state
}

@Directive({ selector: "[appCountryPopup]" })
class CountryPopup {
  readonly state = usePart(inject(CountryPicker).handle, "content").state
}

@Directive({ selector: "[appCountryList]" })
class CountryList {
  readonly state = usePart(inject(CountryPicker).handle, "list").state
}

@Directive({ selector: "[appCountryOption]" })
class CountryOption {
  readonly label: InputSignal<ComboboxItemProps<any>["label"]> = input()
  readonly value = input.required<ComboboxItemProps<any>["value"]>()
  readonly state = usePart(inject(CountryPicker).handle, "item", () => ({
    label: this.label(),
    value: this.value(),
  })).state
}

@Directive({ selector: "[appCountryEmpty]" })
class CountryEmpty {
  readonly state = usePart(inject(CountryPicker).handle, "empty").state
}

export {
  CountryEmpty,
  CountryInput,
  CountryLabel,
  CountryList,
  CountryOption,
  CountryPicker,
  CountryPopup,
}
import { Component } from "@angular/core"
import {
  CountryEmpty,
  CountryInput,
  CountryLabel,
  CountryList,
  CountryOption,
  CountryPicker,
  CountryPopup,
} from "./country-picker"

@Component({
  selector: "app-country-picker-example",
  imports: [
    CountryEmpty,
    CountryInput,
    CountryLabel,
    CountryList,
    CountryOption,
    CountryPicker,
    CountryPopup,
  ],
  template: `
    <ng-container appCountryPicker>
      <label appCountryLabel>Country</label>
      <input appCountryInput />
      <div appCountryPopup>
        <div appCountryEmpty>No countries found.</div>
        <div appCountryList>
          <div appCountryOption value="fr" label="France">France</div>
          <div appCountryOption value="jp" label="Japan">Japan</div>
        </div>
      </div>
    </ng-container>
  `,
})
export class CountryPickerExample {}

Connect the other slots the same way, each with usePart. Each part keeps the behavior, state and data attributes of its ready-made counterpart: typing filters the options, arrow keys move the highlight and the popup opens in the top layer. See Rendering Primitives and Custom Parts for more.

Disabled

A disabled combobox cannot be focused or changed and submits nothing. A read-only one remains focusable and submits its value, but does not open or accept changes. Keyboard navigation skips a disabled option, and it cannot be chosen.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <div data-slot="stack">
      @for (variant of variants; track variant) {
        <ng-container
          uiCombobox
          [defaultValue]="variant === 'item' ? null : 'fr'"
          [itemToLabel]="countryLabel"
          [disabled]="variant === 'disabled'"
          [readOnly]="variant === 'readOnly'"
        >
          <div data-slot="stack">
            <label uiComboboxLabel>
              {{
                variant === "disabled"
                  ? "Billing country"
                  : variant === "readOnly"
                    ? "Shipping from"
                    : "Shipping to"
              }}
            </label>
            <div data-slot="row">
              <input uiComboboxInput placeholder="Search countries…" />
              <button uiComboboxTrigger aria-label="Show countries">
                <svg lucideChevronDown></svg>
              </button>
            </div>
          </div>
          <div *uiComboboxContent>
            <div uiComboboxEmpty>No countries found.</div>
            <div uiComboboxList>
              @for (country of countries; track country.value) {
                <div
                  uiComboboxItem
                  [value]="country.value"
                  [label]="country.label"
                  [disabled]="country.value === 'dk'"
                >
                  {{ country.label }}
                  <span *uiComboboxItemIndicator>
                    <svg lucideCheck></svg>
                  </span>
                </div>
              }
            </div>
          </div>
        </ng-container>
      }
    </div>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina" },
    { value: "au", label: "Australia" },
    { value: "at", label: "Austria" },
    { value: "be", label: "Belgium" },
    { value: "br", label: "Brazil" },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark" },
    { value: "fi", label: "Finland" },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany" },
    { value: "gr", label: "Greece" },
    { value: "jp", label: "Japan" },
    { value: "nl", label: "Netherlands" },
    { value: "es", label: "Spain" },
    { value: "se", label: "Sweden" },
    { value: "ch", label: "Switzerland" },
  ]

  readonly countryLabel = (value: string) =>
    this.countries.find((country) => country.value === value)?.label ?? value

  readonly variants = ["disabled", "readOnly", "item"] as const
}

export { Example }
Billing country is disabled and Shipping from is read-only. Open Shipping to: arrow keys skip Denmark, which can't be chosen.

Clear and Trigger

uiComboboxClear clears both the selection and the query, then keeps focus in the input. It appears while either has a value. When someone deletes all the text, a single selection clears right away instead of when the list closes. Escape brings the selection back while the list is still open; closing it any other way leaves it cleared.

Console
import { Component, signal } from "@angular/core"
import { LucideCheck, LucideChevronDown, LucideX } from "@lucide/angular"
import { useLog } from "./log"
import {
  Combobox,
  ComboboxClear,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxClear,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
    LucideX,
  ],
  template: `
    <ng-container
      uiCombobox
      [(value)]="value"
      (beforeValueChange)="
        log(
          ($event.value ? frameworkLabel($event.value) : 'Cleared') +
            ' (' +
            $event.reason +
            ')'
        )
      "
      [itemToLabel]="frameworkLabel"
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Framework</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Select a framework" />
          <button *uiComboboxClear aria-label="Clear framework">
            <svg lucideX></svg>
          </button>
          <button uiComboboxTrigger aria-label="Show frameworks">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No frameworks found.</div>
        <div uiComboboxList>
          @for (framework of frameworks; track framework.value) {
            <div
              uiComboboxItem
              [value]="framework.value"
              [label]="framework.label"
            >
              {{ framework.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly frameworks = [
    { value: "next", label: "Next.js" },
    { value: "sveltekit", label: "SvelteKit" },
    { value: "nuxt", label: "Nuxt" },
    { value: "remix", label: "Remix" },
    { value: "astro", label: "Astro" },
    { value: "solidstart", label: "SolidStart" },
    { value: "qwik", label: "Qwik City" },
  ]

  readonly frameworkLabel = (value: string) =>
    this.frameworks.find((framework) => framework.value === value)?.label ??
    value

  readonly log = useLog()

  readonly value = signal<string | null>("sveltekit")
}

export { Example }
Choose a framework, then press the clear button. The selection and text clear, focus stays in the input, and the console logs each change.

Auto Highlight

Add autoHighlight to highlight the first match while typing, so Enter can choose it immediately. With autoHighlight="always", opening the list also highlights the selected item, or the first, so the arrow keys move from there. autoHighlight="selected" highlights only the selected item when the list opens, and nothing when none is. A highlight it placed follows the list as items arrive, and one the user moved stays while its item is there.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container uiCombobox [autoHighlight]="true">
      <div data-slot="stack">
        <label uiComboboxLabel>Country</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Type “sw” and press Enter" />
          <button uiComboboxTrigger aria-label="Show countries">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No countries found.</div>
        <div uiComboboxList>
          @for (country of countries; track country.value) {
            <div uiComboboxItem [value]="country.value" [label]="country.label">
              {{ country.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina" },
    { value: "au", label: "Australia" },
    { value: "at", label: "Austria" },
    { value: "be", label: "Belgium" },
    { value: "br", label: "Brazil" },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark" },
    { value: "fi", label: "Finland" },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany" },
    { value: "gr", label: "Greece" },
    { value: "jp", label: "Japan" },
    { value: "nl", label: "Netherlands" },
    { value: "es", label: "Spain" },
    { value: "se", label: "Sweden" },
    { value: "ch", label: "Switzerland" },
  ]
}

export { Example }
Type “sw” and press Enter. The first matching country is already highlighted.

Highlight Matches

uiComboboxItemText marks the matching text. Matching ignores case and accents using the current locale, while the label keeps its original spelling. Its state also exposes segments if you want to render the marks yourself.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxItemText,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxItemText,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container uiCombobox>
      <div data-slot="stack">
        <label uiComboboxLabel>Country</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Search countries…" />
          <button uiComboboxTrigger aria-label="Show countries">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No countries found.</div>
        <div uiComboboxList>
          @for (country of countries; track country.value) {
            <div
              uiComboboxItem
              [value]="country.value"
              [label]="country.label"
              [keywords]="country.keywords"
            >
              <span uiComboboxItemText #comboboxItemText="uiComboboxItemText">
                @for (
                  segment of comboboxItemText.state().segments;
                  track index;
                  let index = $index
                ) {
                  @if (segment.match) {
                    <mark>{{ segment.text }}</mark>
                  } @else {
                    <span>{{ segment.text }}</span>
                  }
                }
              </span>
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina", keywords: ["república argentina"] },
    { value: "au", label: "Australia", keywords: ["oz"] },
    { value: "at", label: "Austria", keywords: ["österreich"] },
    { value: "be", label: "Belgium", keywords: ["belgië", "belgique"] },
    { value: "br", label: "Brazil", keywords: ["brasil"] },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark", keywords: ["danmark"] },
    { value: "fi", label: "Finland", keywords: ["suomi"] },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany", keywords: ["deutschland"] },
    { value: "gr", label: "Greece", keywords: ["hellas", "ελλάδα"] },
    { value: "jp", label: "Japan", keywords: ["nippon", "日本"] },
    { value: "nl", label: "Netherlands", keywords: ["holland", "nederland"] },
    { value: "es", label: "Spain", keywords: ["españa"] },
    { value: "se", label: "Sweden", keywords: ["sverige"] },
    {
      value: "ch",
      label: "Switzerland",
      keywords: ["schweiz", "suisse", "svizzera"],
    },
  ]
}

export { Example }
Type “an”. Matching letters are marked while each country keeps its original spelling.

Filter and Keywords

filter accepts "contains" (the default), "startsWith", a function of the item and query, or false for results already filtered by a server. A function can return a score instead of true or false, and items you pass as items then sort by it, best first. fuzzyScore from @ui-sdk/core/text-match scores an exact match above a prefix, and a prefix above a match inside the label.

Use keywords for text that should match without appearing in the label, such as a username or a country’s local name.

import { Component, signal } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectItemIndicator,
  SelectLabel,
  SelectTrigger,
  SelectValue,
} from "@ui-sdk/angular/select"

function fuzzy(item: { label: string }, query: string) {
  let at = 0
  for (const char of item.label.toLowerCase()) {
    if (char === query[at]?.toLowerCase()) {
      at++
    }
  }
  return at === query.length
}

const filters = {
  contains: "contains",
  startsWith: "startsWith",
  fuzzy,
} as const

type Mode = keyof typeof filters

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    Select,
    SelectContent,
    SelectItem,
    SelectItemIndicator,
    SelectLabel,
    SelectTrigger,
    SelectValue,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <div data-slot="stack">
      <div data-slot="controls">
        <ng-container
          uiSelect
          [items]="modes"
          [value]="mode()"
          (beforeValueChange)="$event.value && mode.set($event.value)"
        >
          <div uiSelectLabel>Filter</div>
          <button uiSelectTrigger>
            <span uiSelectValue></span>
            <svg lucideChevronDown></svg>
          </button>
          <div *uiSelectContent>
            @for (option of modes; track option.value) {
              <div uiSelectItem [value]="option.value">
                {{ option.label }}
                <span *uiSelectItemIndicator>
                  <svg lucideCheck></svg>
                </span>
              </div>
            }
          </div>
        </ng-container>
      </div>
      <ng-container uiCombobox [filter]="filters[mode()]">
        <div data-slot="stack">
          <label uiComboboxLabel>Country</label>
          <div data-slot="row">
            <input
              uiComboboxInput
              placeholder="Try “an”, “swd” or “deutschland”"
            />
            <button uiComboboxTrigger aria-label="Show countries">
              <svg lucideChevronDown></svg>
            </button>
          </div>
        </div>
        <div *uiComboboxContent>
          <div uiComboboxEmpty>No countries found.</div>
          <div uiComboboxList>
            @for (country of countries; track country.value) {
              <div
                uiComboboxItem
                [value]="country.value"
                [label]="country.label"
                [keywords]="country.keywords"
              >
                {{ country.label }}
                <span *uiComboboxItemIndicator>
                  <svg lucideCheck></svg>
                </span>
              </div>
            }
          </div>
        </div>
      </ng-container>
    </div>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina", keywords: ["república argentina"] },
    { value: "au", label: "Australia" },
    { value: "at", label: "Austria", keywords: ["österreich"] },
    { value: "be", label: "Belgium", keywords: ["belgië", "belgique"] },
    { value: "br", label: "Brazil", keywords: ["brasil"] },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark", keywords: ["danmark"] },
    { value: "fi", label: "Finland", keywords: ["suomi"] },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany", keywords: ["deutschland"] },
    { value: "gr", label: "Greece", keywords: ["hellas", "ελλάδα"] },
    { value: "jp", label: "Japan", keywords: ["nippon", "日本"] },
    { value: "nl", label: "Netherlands", keywords: ["holland", "nederland"] },
    { value: "es", label: "Spain", keywords: ["españa"] },
    { value: "se", label: "Sweden", keywords: ["sverige"] },
    {
      value: "ch",
      label: "Switzerland",
      keywords: ["schweiz", "suisse", "svizzera"],
    },
  ]

  readonly filters = filters

  readonly modes = [
    { value: "contains", label: "Contains" },
    { value: "startsWith", label: "Starts with" },
    { value: "fuzzy", label: "Fuzzy" },
  ]

  readonly mode = signal<Mode>("contains")
}

export { Example }
Type “an” and switch Filter between Contains and Starts with. Choose Fuzzy and type “swd” for Sweden, or type “deutschland” to find Germany through a keyword.

Groups

Use uiComboboxGroup and uiComboboxGroupLabel to name groups. Filtering hides empty groups and separators as their items disappear.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxGroup,
  ComboboxGroupLabel,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxSeparator,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxGroup,
    ComboboxGroupLabel,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxSeparator,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container uiCombobox>
      <div data-slot="stack">
        <label uiComboboxLabel>Timezone</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Search cities…" />
          <button uiComboboxTrigger aria-label="Show timezones">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No cities found.</div>
        <div uiComboboxList>
          @for (group of timezones; track group.label; let index = $index) {
            @if (index > 0) {
              <div uiComboboxSeparator></div>
            }
            <div uiComboboxGroup>
              <div uiComboboxGroupLabel>
                {{ group.label }}
              </div>
              @for (item of group.items; track item.value) {
                <div uiComboboxItem [value]="item.value" [label]="item.label">
                  {{ item.label }}
                  <span *uiComboboxItemIndicator>
                    <svg lucideCheck></svg>
                  </span>
                </div>
              }
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly timezones = [
    {
      label: "Americas",
      items: [
        { value: "America/New_York", label: "New York" },
        { value: "America/Chicago", label: "Chicago" },
        { value: "America/Denver", label: "Denver" },
        { value: "America/Los_Angeles", label: "Los Angeles" },
        { value: "America/Sao_Paulo", label: "São Paulo" },
      ],
    },
    {
      label: "Europe",
      items: [
        { value: "Europe/London", label: "London" },
        { value: "Europe/Paris", label: "Paris" },
        { value: "Europe/Berlin", label: "Berlin" },
        { value: "Europe/Madrid", label: "Madrid" },
      ],
    },
    {
      label: "Asia & Pacific",
      items: [
        { value: "Asia/Tokyo", label: "Tokyo" },
        { value: "Asia/Singapore", label: "Singapore" },
        { value: "Asia/Kolkata", label: "Kolkata" },
        { value: "Australia/Sydney", label: "Sydney" },
      ],
    },
  ]
}

export { Example }
Type “chic”. Chicago remains in Americas; groups with no matches disappear.

Icons

uiComboboxItemIcon keeps decorative icons out of accessible names, filtering, and match marks. uiComboboxValueIcon projects the selected item’s icon next to the input; you leave it empty, and it is only for a single selection.

Wrap the input and icon together, then use that wrapper as the popup’s anchor. Add mirror for directional icons. An icon-only option still needs an aria-label.

import { Component } from "@angular/core"
import {
  LucideArrowRight,
  LucideCheck,
  LucideChevronDown,
  LucideCircle,
  LucideCircleCheck,
  LucideCircleX,
} from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIcon,
  ComboboxItemIndicator,
  ComboboxItemText,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
  ComboboxValueIcon,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIcon,
    ComboboxItemIndicator,
    ComboboxItemText,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    ComboboxValueIcon,
    LucideArrowRight,
    LucideCheck,
    LucideChevronDown,
    LucideCircle,
    LucideCircleCheck,
    LucideCircleX,
  ],
  template: `
    <ng-container uiCombobox>
      <div data-slot="stack">
        <label uiComboboxLabel>Status</label>
        <div #field data-slot="row">
          <span uiComboboxValueIcon></span>
          <input uiComboboxInput placeholder="Select a status" />
          <button uiComboboxTrigger aria-label="Show statuses">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent="{ anchor: field }">
        <div uiComboboxEmpty>No statuses found.</div>
        <div uiComboboxList>
          <div uiComboboxItem value="backlog" label="Backlog">
            <span uiComboboxItemIcon>
              <svg lucideCircle></svg>
            </span>
            <span uiComboboxItemText></span>
            <span *uiComboboxItemIndicator>
              <svg lucideCheck></svg>
            </span>
          </div>
          <div uiComboboxItem value="in-progress" label="In progress">
            <span uiComboboxItemIcon mirror>
              <svg lucideArrowRight></svg>
            </span>
            <span uiComboboxItemText></span>
            <span *uiComboboxItemIndicator>
              <svg lucideCheck></svg>
            </span>
          </div>
          <div uiComboboxItem value="done" label="Done">
            <span uiComboboxItemIcon>
              <svg lucideCircleCheck></svg>
            </span>
            <span uiComboboxItemText></span>
            <span *uiComboboxItemIndicator>
              <svg lucideCheck></svg>
            </span>
          </div>
          <div uiComboboxItem value="canceled" label="Canceled">
            <span uiComboboxItemIcon>
              <svg lucideCircleX></svg>
            </span>
            <span uiComboboxItemText></span>
            <span *uiComboboxItemIndicator>
              <svg lucideCheck></svg>
            </span>
          </div>
        </div>
      </div>
    </ng-container>
  `,
})
class Example {}

export { Example }
Choose Done. Its icon appears next to the input as well as in the list.

Custom Items

Show useful context beside a label, such as a username or role. Set label explicitly so filtering and the input use the intended text, and put extra search terms in keywords.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container uiCombobox>
      <div data-slot="stack">
        <label uiComboboxLabel>Owner</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Search people…" />
          <button uiComboboxTrigger aria-label="Show people">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No people found.</div>
        <div uiComboboxList>
          @for (user of users; track user.id) {
            <div
              uiComboboxItem
              [value]="user.username"
              [label]="user.name"
              [keywords]="[user.username]"
            >
              <span data-slot="badge">
                {{ user.name.slice(0, 1) }}
              </span>
              <span data-slot="stack">
                <span>{{ user.name }}</span>
                <span data-slot="hint">@{{ user.username }}</span>
              </span>
              <span data-slot="hint">
                {{ user.role }}
              </span>
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly users = [
    { id: 1, name: "Hollis Grant", username: "hollis", role: "Owner" },
    { id: 2, name: "Inès Moreau", username: "ines", role: "Admin" },
    { id: 3, name: "Kofi Mensah", username: "kofi", role: "Member" },
    { id: 4, name: "Wren Takahashi", username: "wren", role: "Member" },
    { id: 5, name: "Tomasz Wójcik", username: "tomasz", role: "Guest" },
  ]
}

export { Example }
Search for a person’s name or username. Choose a result to put that person’s name in the input.

Items as Data

Pass items when the combobox needs the whole collection, such as recent items, server results, or virtualization. uiComboboxItems inside the list renders bare parts for you, or you can render the parts yourself from the list's state().items. Each item's label supplies the text for filtering and the input; keywords and disabled work the same as with items you render yourself. Lists and Menus covers the ListData format.

import { Component } from "@angular/core"
import { Combobox, ComboboxInput } from "@ui-sdk/angular/combobox"

@Component({
  selector: "app-example",
  imports: [Combobox, ComboboxInput],
  template: `
    <ng-container uiCombobox [items]="fruits">
      <input uiComboboxInput aria-label="Fruit" />
    </ng-container>
  `,
})
class Example {
  readonly fruits = [
    { value: "apple", label: "Apple" },
    { value: "cherry", label: "Cherry", keywords: ["red"] },
    {
      type: "group",
      label: "Citrus",
      items: [{ value: "lemon", label: "Lemon" }],
    },
  ]
}

export { Example }

Items can change while the list is open. Selection and highlight stay on their items; removing the highlighted item clears the highlight.

Recent Items

emptyItems supplies suggestions while the query is empty. Pair it with items for the full searchable collection. Render the list from its state().items so it follows the active collection.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxGroup,
  ComboboxGroupLabel,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxItemText,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"
import { type ListAnnouncement } from "@ui-sdk/core/combobox"

const countries = [
  { value: "ar", label: "Argentina", keywords: ["república argentina"] },
  { value: "au", label: "Australia", keywords: ["oz"] },
  { value: "at", label: "Austria", keywords: ["österreich"] },
  { value: "be", label: "Belgium", keywords: ["belgië", "belgique"] },
  { value: "br", label: "Brazil", keywords: ["brasil"] },
  { value: "ca", label: "Canada" },
  { value: "cl", label: "Chile" },
  { value: "dk", label: "Denmark", keywords: ["danmark"] },
  { value: "fi", label: "Finland", keywords: ["suomi"] },
  { value: "fr", label: "France" },
  { value: "de", label: "Germany", keywords: ["deutschland"] },
  { value: "gr", label: "Greece", keywords: ["hellas", "ελλάδα"] },
  { value: "jp", label: "Japan", keywords: ["nippon", "日本"] },
  { value: "nl", label: "Netherlands", keywords: ["holland", "nederland"] },
  { value: "es", label: "Spain", keywords: ["españa"] },
  { value: "se", label: "Sweden", keywords: ["sverige"] },
  {
    value: "ch",
    label: "Switzerland",
    keywords: ["schweiz", "suisse", "svizzera"],
  },
]

const recentCountries = [
  {
    type: "group" as const,
    label: "Recent",
    items: [countries[9], countries[12], countries[15]],
  },
]

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxGroup,
    ComboboxGroupLabel,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxItemText,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container
      uiCombobox
      [items]="countries"
      [emptyItems]="recentCountries"
      [announcement]="announcement"
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Country</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Search countries…" />
          <button uiComboboxTrigger aria-label="Show countries">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No countries found.</div>
        <div uiComboboxList #comboboxList="uiComboboxList">
          @for (
            entry of itemsOf(comboboxList.state().items);
            track "items" in entry ? entry.label : entry.value
          ) {
            @if ("items" in entry) {
              <div uiComboboxGroup>
                <div uiComboboxGroupLabel>{{ entry.label }}</div>
                @for (country of entry.items; track country.value) {
                  <div
                    uiComboboxItem
                    [value]="country.value"
                    [label]="country.label"
                  >
                    <span uiComboboxItemText></span>
                    <span *uiComboboxItemIndicator>
                      <svg lucideCheck></svg>
                    </span>
                  </div>
                }
              </div>
            } @else {
              <div uiComboboxItem [value]="entry.value" [label]="entry.label">
                <span uiComboboxItemText></span>
                <span *uiComboboxItemIndicator>
                  <svg lucideCheck></svg>
                </span>
              </div>
            }
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly countries = countries

  readonly recentCountries = recentCountries

  readonly announcement = (change: ListAnnouncement) =>
    change.type === "results" ? `${change.count} countries match` : null

  itemsOf(items: unknown) {
    return items as (
      (typeof countries)[number] | (typeof recentCountries)[number]
    )[]
  }
}

export { Example }
Open the empty input to see Recent. Start typing to search all countries; clear the text to return to Recent.

Object Values

Use itemToValue for an object’s string identity and form value, itemToLabel for its displayed text, and isItemEqualToValue when two different objects can represent the same option.

import { Component } from "@angular/core"
import { Combobox } from "@ui-sdk/angular/combobox"

type Person = { id: number; name: string }

@Component({
  selector: "app-example",
  imports: [Combobox],
  template: `
    <ng-container
      uiCombobox
      name="reviewer"
      [itemToValue]="itemToValue"
      [itemToLabel]="itemToLabel"
      [isItemEqualToValue]="isItemEqualToValue"
    ></ng-container>
  `,
})
class Example {
  readonly itemToValue = (person: Person) => String(person.id)

  readonly itemToLabel = (person: Person) => person.name

  readonly isItemEqualToValue = (person: Person, value: Person) =>
    person.id === value.id
}

export { Example }

Multiple

Add multiple to make the value an array. Choosing an option toggles it, keeps the list open, and clears the query. Put uiComboboxValue and the input inside uiComboboxChips, then render each value as a chip with a removal button.

Backspace in an empty input removes the last chip in one press. Unlike Token Input, there is no tokenDeletion option to select it first. Arrow keys move between chips. Supply itemToLabel when starting with values whose labels are not yet known from rendered items.

Add keepQuery to choose several matches without retyping the query.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown, LucideX } from "@lucide/angular"
import {
  Combobox,
  ComboboxChip,
  ComboboxChipRemove,
  ComboboxChips,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
  ComboboxValue,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxChip,
    ComboboxChipRemove,
    ComboboxChips,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    ComboboxValue,
    LucideCheck,
    LucideChevronDown,
    LucideX,
  ],
  template: `
    <ng-container
      uiCombobox
      multiple
      [defaultValue]="['next', 'astro']"
      [itemToLabel]="frameworkLabel"
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Frameworks</label>
        <div data-slot="row">
          <div uiComboboxChips>
            <span uiComboboxValue #comboboxValue="uiComboboxValue">
              @for (
                value of itemsOf(comboboxValue.state().value);
                track value;
                let index = $index
              ) {
                <div uiComboboxChip [value]="value">
                  {{ comboboxValue.state().labels[index] }}
                  <button
                    uiComboboxChipRemove
                    [attr.aria-label]="\`Remove \${comboboxValue.state().labels[index]}\`"
                  >
                    <svg lucideX></svg>
                  </button>
                </div>
              }
            </span>
            <input uiComboboxInput placeholder="Add a framework…" />
          </div>
          <button uiComboboxTrigger aria-label="Show frameworks">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No frameworks found.</div>
        <div uiComboboxList>
          @for (framework of frameworks; track framework.value) {
            <div
              uiComboboxItem
              [value]="framework.value"
              [label]="framework.label"
            >
              {{ framework.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly frameworks = [
    { value: "next", label: "Next.js" },
    { value: "sveltekit", label: "SvelteKit" },
    { value: "nuxt", label: "Nuxt" },
    { value: "remix", label: "Remix" },
    { value: "astro", label: "Astro" },
    { value: "solidstart", label: "SolidStart" },
    { value: "qwik", label: "Qwik City" },
  ]

  readonly frameworkLabel = (value: string) =>
    this.frameworks.find((framework) => framework.value === value)?.label ??
    value

  itemsOf(items: unknown) {
    return items as string[]
  }
}

export { Example }
Choose several frameworks. Remove one with its chip button, or press Backspace in the empty input to remove the last chip.

Select All

uiComboboxSelectAll toggles every matching, enabled option. Inside a group, it affects only that group. It joins keyboard navigation and reports a mixed state while some of its options are selected.

import { Component } from "@angular/core"
import { LucideCheck, LucideMinus, LucideX } from "@lucide/angular"
import {
  Combobox,
  ComboboxChip,
  ComboboxChipRemove,
  ComboboxChips,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxGroup,
  ComboboxGroupLabel,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxSelectAll,
  ComboboxValue,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxChip,
    ComboboxChipRemove,
    ComboboxChips,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxGroup,
    ComboboxGroupLabel,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxSelectAll,
    ComboboxValue,
    LucideCheck,
    LucideMinus,
    LucideX,
  ],
  template: `
    <ng-container uiCombobox multiple [defaultValue]="['Europe/Paris']">
      <div data-slot="stack">
        <label uiComboboxLabel>Timezones</label>
        <div uiComboboxChips>
          <span uiComboboxValue #comboboxValue="uiComboboxValue">
            @for (
              value of itemsOf(comboboxValue.state().value);
              track value;
              let index = $index
            ) {
              <div uiComboboxChip [value]="value">
                {{ comboboxValue.state().labels[index] }}
                <button
                  uiComboboxChipRemove
                  [attr.aria-label]="\`Remove \${comboboxValue.state().labels[index]}\`"
                >
                  <svg lucideX></svg>
                </button>
              </div>
            }
          </span>
          <input uiComboboxInput placeholder="Add timezones…" />
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No timezones found.</div>
        <div uiComboboxList>
          <div uiComboboxSelectAll>
            <span>
              <svg lucideCheck></svg>
              <svg lucideMinus></svg>
            </span>
            Select all
          </div>
          @for (group of timezones; track group.label) {
            <div uiComboboxGroup>
              <div uiComboboxGroupLabel>
                {{ group.label }}
              </div>
              <div uiComboboxSelectAll #comboboxSelectAll="uiComboboxSelectAll">
                {{
                  comboboxSelectAll.state().checked
                    ? "Clear " + group.label
                    : "Select all in " + group.label
                }}
              </div>
              @for (zone of group.items; track zone.value) {
                <div uiComboboxItem [value]="zone.value" [label]="zone.label">
                  <span>
                    <span *uiComboboxItemIndicator>
                      <svg lucideCheck></svg>
                    </span>
                  </span>
                  {{ zone.label }}
                </div>
              }
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly timezones = [
    {
      label: "Americas",
      items: [
        { value: "America/New_York", label: "New York" },
        { value: "America/Chicago", label: "Chicago" },
        { value: "America/Denver", label: "Denver" },
        { value: "America/Los_Angeles", label: "Los Angeles" },
        { value: "America/Sao_Paulo", label: "São Paulo" },
      ],
    },
    {
      label: "Europe",
      items: [
        { value: "Europe/London", label: "London" },
        { value: "Europe/Paris", label: "Paris" },
        { value: "Europe/Berlin", label: "Berlin" },
        { value: "Europe/Madrid", label: "Madrid" },
      ],
    },
    {
      label: "Asia & Pacific",
      items: [
        { value: "Asia/Tokyo", label: "Tokyo" },
        { value: "Asia/Singapore", label: "Singapore" },
        { value: "Asia/Kolkata", label: "Kolkata" },
        { value: "Australia/Sydney", label: "Sydney" },
      ],
    },
  ]

  itemsOf(items: unknown) {
    return items as string[]
  }
}

export { Example }
Open the list and choose a group’s select-all option. Type to narrow the matches, then use the main select-all option on those results.

Chips That Collapse

Add uiComboboxChipsOverflow to keep chips on one line. It measures which chips fit, hides the rest, and exposes their count and labels. Separately, uiComboboxValue can use max to show a short text summary of the selection.

import { Component } from "@angular/core"
import { LucideCheck, LucideX } from "@lucide/angular"
import {
  Combobox,
  ComboboxChip,
  ComboboxChipRemove,
  ComboboxChips,
  ComboboxChipsOverflow,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxValue,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxChip,
    ComboboxChipRemove,
    ComboboxChips,
    ComboboxChipsOverflow,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxValue,
    LucideCheck,
    LucideX,
  ],
  template: `
    <ng-container
      uiCombobox
      multiple
      [defaultValue]="['fr', 'jp', 'se', 'de', 'ch']"
      [itemToLabel]="countryLabel"
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Countries</label>
        <div uiComboboxChips>
          <span uiComboboxValue #comboboxValue="uiComboboxValue">
            @for (
              value of itemsOf(comboboxValue.state().value);
              track value;
              let index = $index
            ) {
              <div uiComboboxChip [value]="value">
                {{ comboboxValue.state().labels[index] }}
                <button
                  uiComboboxChipRemove
                  [attr.aria-label]="\`Remove \${comboboxValue.state().labels[index]}\`"
                >
                  <svg lucideX></svg>
                </button>
              </div>
            }
          </span>
          <span
            uiComboboxChipsOverflow
            #comboboxChipsOverflow="uiComboboxChipsOverflow"
            [title]="comboboxChipsOverflow.state().labels.join(', ')"
            data-slot="hint"
          >
            +{{ comboboxChipsOverflow.state().count }}
          </span>
          <input uiComboboxInput placeholder="Add…" />
        </div>
        <p data-slot="hint">
          <span
            uiComboboxValue
            [maxLabels]="2"
            [getMoreLabel]="getMoreLabel"
          ></span>
        </p>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No countries found.</div>
        <div uiComboboxList>
          @for (country of countries; track country.value) {
            <div uiComboboxItem [value]="country.value" [label]="country.label">
              {{ country.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina", keywords: ["república argentina"] },
    { value: "au", label: "Australia", keywords: ["oz"] },
    { value: "at", label: "Austria", keywords: ["österreich"] },
    { value: "be", label: "Belgium", keywords: ["belgië", "belgique"] },
    { value: "br", label: "Brazil", keywords: ["brasil"] },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark", keywords: ["danmark"] },
    { value: "fi", label: "Finland", keywords: ["suomi"] },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany", keywords: ["deutschland"] },
    { value: "gr", label: "Greece", keywords: ["hellas", "ελλάδα"] },
    { value: "jp", label: "Japan", keywords: ["nippon", "日本"] },
    { value: "nl", label: "Netherlands", keywords: ["holland", "nederland"] },
    { value: "es", label: "Spain", keywords: ["españa"] },
    { value: "se", label: "Sweden", keywords: ["sverige"] },
    {
      value: "ch",
      label: "Switzerland",
      keywords: ["schweiz", "suisse", "svizzera"],
    },
  ]

  readonly countryLabel = (value: string) =>
    this.countries.find((country) => country.value === value)?.label ?? value

  itemsOf(items: unknown) {
    return items as string[]
  }

  readonly getMoreLabel = (count: number) => `${count} more`
}

export { Example }
Add or remove countries. Chips that no longer fit are replaced by an overflow count; the summary below lists the first two.

Max Selected

maxSelected limits a multiple selection. Once the limit is reached, other options become disabled; their maxReached state explains why.

import { Component } from "@angular/core"
import { LucideCheck, LucideX } from "@lucide/angular"
import {
  Combobox,
  ComboboxChip,
  ComboboxChipRemove,
  ComboboxChips,
  ComboboxContent,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxValue,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxChip,
    ComboboxChipRemove,
    ComboboxChips,
    ComboboxContent,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxValue,
    LucideCheck,
    LucideX,
  ],
  template: `
    <ng-container
      uiCombobox
      multiple
      [maxSelected]="3"
      [defaultValue]="['Bug', 'Design']"
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Labels (up to 3)</label>
        <div uiComboboxChips>
          <span uiComboboxValue #comboboxValue="uiComboboxValue">
            @for (label of itemsOf(comboboxValue.state().value); track label) {
              <div uiComboboxChip [value]="label">
                {{ label }}
                <button
                  uiComboboxChipRemove
                  [attr.aria-label]="\`Remove \${label}\`"
                >
                  <svg lucideX></svg>
                </button>
              </div>
            }
          </span>
          <input uiComboboxInput placeholder="Add labels…" />
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxList>
          @for (label of labels; track label) {
            <div uiComboboxItem #comboboxItem="uiComboboxItem" [value]="label">
              {{ label }}
              @if (comboboxItem.state().maxReached) {
                <span data-slot="hint">Limit reached</span>
              }
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly labels = [
    "Bug",
    "Feature",
    "Documentation",
    "Design",
    "Performance",
    "Security",
    "Testing",
  ]

  itemsOf(items: unknown) {
    return items as string[]
  }
}

export { Example }
Choose a third label. Other unselected labels become unavailable until you remove one.

Create Option

uiComboboxCreate offers the query when no label matches it exactly and it meets minLength. Use (create) to save it, and pass a promise to $event.waitUntil() for asynchronous work. Creation does not change the selection itself: add the new item and select it after saving.

While saving, the option reports data-pending, aria-busy and aria-disabled. A rejected promise is available through its error state.

import { Component, signal } from "@angular/core"
import {
  LucideCheck,
  LucideLoaderCircle,
  LucidePlus,
  LucideX,
} from "@lucide/angular"
import {
  Combobox,
  ComboboxChip,
  ComboboxChipRemove,
  ComboboxChips,
  ComboboxContent,
  ComboboxCreate,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxValue,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxChip,
    ComboboxChipRemove,
    ComboboxChips,
    ComboboxContent,
    ComboboxCreate,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxValue,
    LucideCheck,
    LucideLoaderCircle,
    LucidePlus,
    LucideX,
  ],
  template: `
    <ng-container uiCombobox [(value)]="value" multiple>
      <div data-slot="stack">
        <label uiComboboxLabel>Labels</label>
        <div uiComboboxChips>
          <span uiComboboxValue #comboboxValue="uiComboboxValue">
            @for (label of itemsOf(comboboxValue.state().value); track label) {
              <div uiComboboxChip [value]="label">
                {{ label }}
                <button
                  uiComboboxChipRemove
                  [attr.aria-label]="\`Remove \${label}\`"
                >
                  <svg lucideX></svg>
                </button>
              </div>
            }
          </span>
          <input uiComboboxInput placeholder="Add or create a label…" />
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxList>
          @for (label of labels(); track label) {
            <div uiComboboxItem [value]="label">
              {{ label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
          <div
            uiComboboxCreate
            #comboboxCreate="uiComboboxCreate"
            [minLength]="2"
            (create)="$event.waitUntil(create($event.query))"
          >
            @if (comboboxCreate.state().pending) {
              <svg lucideLoaderCircle data-slot="spinner"></svg>
              Creating “{{ comboboxCreate.state().query }}”…
            } @else {
              <svg lucidePlus></svg>
              <span data-slot="stack">
                Create “{{ comboboxCreate.state().query }}”
                @if (comboboxCreate.state().error) {
                  <span data-slot="hint">{{
                    messageOf(comboboxCreate.state().error)
                  }}</span>
                }
              </span>
            }
          </div>
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly initialLabels = [
    "Bug",
    "Feature",
    "Documentation",
    "Design",
    "Performance",
    "Security",
    "Testing",
  ]

  saveLabel(name: string) {
    return new Promise<void>((resolve, reject) =>
      setTimeout(
        () =>
          name.length > 20
            ? reject(new Error("Labels are 20 characters at most."))
            : resolve(),
        800
      )
    )
  }

  readonly labels = signal(this.initialLabels)

  readonly value = signal<string[]>(["Bug"])

  async create(query: string) {
    await this.saveLabel(query)
    this.labels.set([...this.labels(), query])
    this.value.set([...this.value(), query])
  }

  itemsOf(items: unknown) {
    return items as string[]
  }

  messageOf(error: unknown) {
    return error instanceof Error ? error.message : ""
  }
}

export { Example }
Type a new label and choose Create. It becomes a selected chip after saving; a label longer than 20 characters shows an error.

Custom Value

Use allowCustomValue when suggestions are optional, like a datalist. Unmatched text becomes the value on Enter with nothing highlighted, or when the list closes. This does not create a new item in the collection.

Console
import { Component, signal } from "@angular/core"
import { LucideCheck } from "@lucide/angular"
import { useLog } from "./log"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    LucideCheck,
  ],
  template: `
    <ng-container
      uiCombobox
      allowCustomValue
      [(value)]="value"
      (beforeValueChange)="
        log(
          ($event.value ? '“' + $event.value + '”' : 'No title') +
            ' (' +
            $event.reason +
            ')'
        )
      "
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Job title</label>
        <input uiComboboxInput placeholder="Type any title…" />
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty #comboboxEmpty="uiComboboxEmpty">
          @if (comboboxEmpty.state().empty) {
            Press Enter to use “{{ comboboxEmpty.state().query }}”.
          }
        </div>
        <div uiComboboxList>
          @for (title of titles; track title) {
            <div uiComboboxItem [value]="title">
              {{ title }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly titles = [
    "Designer",
    "Engineer",
    "Engineering manager",
    "Product manager",
    "Researcher",
  ]

  readonly log = useLog()

  readonly value = signal<string | null>(null)
}

export { Example }
Type a job title that isn't suggested, then press Enter without a highlighted option or leave the field. The text becomes the value, and the console logs it.

Input in the Popup

The input can live inside the popup, opened by a button showing the current value. The button then stays in the tab order. Anchor the content to it, clear the query when opening, and return focus to it after closing, as this example does.

import { Component, signal } from "@angular/core"
import { LucideCheck, LucideChevronDown, LucideSearch } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxList,
  ComboboxTrigger,
  ComboboxValue,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxList,
    ComboboxTrigger,
    ComboboxValue,
    LucideCheck,
    LucideChevronDown,
    LucideSearch,
  ],
  template: `
    <ng-container
      uiCombobox
      [(query)]="query"
      defaultValue="jp"
      [itemToLabel]="countryLabel"
      (beforeOpenChange)="$event.value && query.set('')"
      (openChangeComplete)="!$event && button?.focus()"
    >
      <button uiComboboxTrigger aria-label="Country" #button>
        <span>
          <span uiComboboxValue #comboboxValue="uiComboboxValue">
            {{ comboboxValue.state().label || "Select a country" }}
          </span>
        </span>
        <svg lucideChevronDown></svg>
      </button>
      <div *uiComboboxContent="{ anchor: button }">
        <div data-slot="row">
          <svg lucideSearch></svg>
          <input
            uiComboboxInput
            autofocus
            aria-label="Search countries"
            placeholder="Search…"
          />
        </div>
        <div uiComboboxEmpty>No countries found.</div>
        <div uiComboboxList>
          @for (country of countries; track country.value) {
            <div uiComboboxItem [value]="country.value" [label]="country.label">
              {{ country.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina" },
    { value: "au", label: "Australia" },
    { value: "at", label: "Austria" },
    { value: "be", label: "Belgium" },
    { value: "br", label: "Brazil" },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark" },
    { value: "fi", label: "Finland" },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany" },
    { value: "gr", label: "Greece" },
    { value: "jp", label: "Japan" },
    { value: "nl", label: "Netherlands" },
    { value: "es", label: "Spain" },
    { value: "se", label: "Sweden" },
    { value: "ch", label: "Switzerland" },
  ]

  readonly countryLabel = (value: string) =>
    this.countries.find((country) => country.value === value)?.label ?? value

  readonly query = signal("")
}

export { Example }
Press Country to open the search field inside the popup. Choose a country; closing the popup returns focus to the button.

Use useAsyncOptions to debounce a search and discard stale results. Pass its items and status to the combobox, set filter to false, and send query changes to the loader.

uiComboboxStatus and uiComboboxEmpty provide loading, error, and empty messages. Without a custom status, the combobox announces the result count once typing pauses.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import { useAsyncOptions } from "@ui-sdk/angular/async-options"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxStatus,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxStatus,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container
      uiCombobox
      [items]="movies.state().items"
      defaultQuery="the"
      [filter]="false"
      [status]="movies.state().status"
      (beforeQueryChange)="movies.setQuery($event.value)"
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Movie</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Search movies…" />
          <button uiComboboxTrigger aria-label="Show movies">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxStatus #comboboxStatus="uiComboboxStatus">
          {{ comboboxStatus.state().status === 'error'
              ? 'Couldn't load movies.'
              : comboboxStatus.state().loading
                ? 'Searching…'
                : comboboxStatus.state().count + ' ' + (comboboxStatus.state().count === 1 ? 'movie' : 'movies') }}
        </div>
        <div uiComboboxEmpty #comboboxEmpty="uiComboboxEmpty">
          @if (comboboxEmpty.state().empty && !comboboxEmpty.state().loading) {
            No movies match “{{ comboboxEmpty.state().query }}”.
          }
        </div>
        <div uiComboboxList #comboboxList="uiComboboxList">
          @for (item of itemsOf(comboboxList.state().items); track item.value) {
            <div
              uiComboboxItem
              [value]="item.value"
              [label]="item.label"
              [disabled]="item.disabled"
            >
              {{ item.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly movieTitles = [
    "The Shawshank Redemption",
    "The Godfather",
    "The Dark Knight",
    "Pulp Fiction",
    "Schindler's List",
    "The Lord of the Rings",
    "Fight Club",
    "Forrest Gump",
    "Inception",
    "The Matrix",
    "Goodfellas",
    "Interstellar",
    "Parasite",
    "Spirited Away",
    "Whiplash",
    "The Prestige",
    "The Departed",
    "Gladiator",
    "Alien",
    "Casablanca",
    "Amélie",
    "Arrival",
  ]

  readonly searchMovies = (
    query: string,
    { signal }: { signal: AbortSignal }
  ) => {
    return new Promise<{ value: string; label: string }[]>(
      (resolve, reject) => {
        const timer = setTimeout(() => {
          const needle = query.trim().toLowerCase()
          resolve(
            this.movieTitles
              .filter((title) => title.toLowerCase().includes(needle))
              .map((title) => ({
                value: title.toLowerCase().replace(/\W+/g, "-"),
                label: title,
              }))
          )
        }, 500)
        signal.addEventListener("abort", () => {
          clearTimeout(timer)
          reject(signal.reason)
        })
      }
    )
  }

  readonly movies = useAsyncOptions(this.searchMovies, {
    debounce: 300,
    query: "the",
    immediate: true,
  })

  itemsOf(items: unknown) {
    return items as { value: string; label: string; disabled?: boolean }[]
  }
}

export { Example }
Replace “the” with another movie title. The status shows the pending search, then the latest results.

Load More

(loadMore) runs when scrolling or highlighting reaches the last option, once per page and not while a page loads. Connect it to the async loader’s loadMore(); return { items, hasMore } from each page.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import { useAsyncOptions } from "@ui-sdk/angular/async-options"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxStatus,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxStatus,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container
      uiCombobox
      [items]="movies.state().items"
      [filter]="false"
      [status]="movies.state().status"
      (beforeQueryChange)="movies.setQuery($event.value)"
      (loadMore)="movies.loadMore()"
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Movie</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Search movies…" />
          <button uiComboboxTrigger aria-label="Show movies">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty #comboboxEmpty="uiComboboxEmpty">
          @if (comboboxEmpty.state().empty && !comboboxEmpty.state().loading) {
            No movies found.
          }
        </div>
        <div uiComboboxList #comboboxList="uiComboboxList">
          @for (item of itemsOf(comboboxList.state().items); track item.value) {
            <div
              uiComboboxItem
              [value]="item.value"
              [label]="item.label"
              [disabled]="item.disabled"
            >
              {{ item.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
        <div uiComboboxStatus #comboboxStatus="uiComboboxStatus">
          {{
            comboboxStatus.state().loading
              ? "Loading more…"
              : movies.state().hasMore
                ? comboboxStatus.state().count + " loaded"
                : "All " + comboboxStatus.state().count
          }}
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly movieTitles = [
    "The Shawshank Redemption",
    "The Godfather",
    "The Dark Knight",
    "Pulp Fiction",
    "Schindler's List",
    "The Lord of the Rings",
    "Fight Club",
    "Forrest Gump",
    "Inception",
    "The Matrix",
    "Goodfellas",
    "Interstellar",
    "Parasite",
    "Spirited Away",
    "Whiplash",
    "The Prestige",
    "The Departed",
    "Gladiator",
    "Alien",
    "Casablanca",
    "Amélie",
    "Arrival",
  ]

  readonly searchMoviePages = (
    query: string,
    { signal, page }: { signal: AbortSignal; page: number }
  ) => {
    return new Promise<{
      items: { value: string; label: string }[]
      hasMore: boolean
    }>((resolve, reject) => {
      const timer = setTimeout(() => {
        const needle = query.trim().toLowerCase()
        const found = this.movieTitles
          .filter((title) => title.toLowerCase().includes(needle))
          .map((title) => ({
            value: title.toLowerCase().replace(/\W+/g, "-"),
            label: title,
          }))
        resolve({
          items: found.slice(page * 5, page * 5 + 5),
          hasMore: found.length > page * 5 + 5,
        })
      }, 500)
      signal.addEventListener("abort", () => {
        clearTimeout(timer)
        reject(signal.reason)
      })
    })
  }

  readonly movies = useAsyncOptions(this.searchMoviePages, { immediate: true })

  itemsOf(items: unknown) {
    return items as { value: string; label: string; disabled?: boolean }[]
  }
}

export { Example }
Open the movies and scroll or arrow to the last result. Another page loads while the existing results stay available.

Virtualized

Supply items so filtering and keyboard navigation know about every option, even when only a few rows render. The list’s state().items contains matches, (highlight) reports the row to reveal, and each rendered item’s index gives its position in the full list to screen readers.

This example windows 10,000 items. Keep the actual row height aligned with your virtualizer’s measurement, and use the scroller’s visible height when revealing a row.

import { Component, ElementRef, signal, viewChild } from "@angular/core"
import { LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  type ComboboxHighlight,
  ComboboxInput,
  ComboboxItem,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

type Item = { value: string; label: string }

const manyItems: Item[] = Array.from({ length: 10_000 }, (_, index) => ({
  value: `item-${index + 1}`,
  label: `Item ${index + 1}`,
}))

function visibleRows(
  scrollTop: number,
  height: number,
  count: number,
  row: number
) {
  const start = Math.max(0, Math.floor(scrollTop / row) - 4)
  const end = Math.min(count, Math.ceil((scrollTop + height) / row) + 4)
  return { start, end }
}

function scrollForRow(
  index: number,
  scrollTop: number,
  height: number,
  row: number
) {
  const top = index * row
  if (top < scrollTop) {
    return top
  }
  if (top + row > scrollTop + height) {
    return top + row - height
  }
  return scrollTop
}

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideChevronDown,
  ],
  template: `
    <ng-container
      uiCombobox
      [items]="manyItems"
      (highlight)="scrollToRow($event)"
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Item</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Search 10,000 items…" />
          <button uiComboboxTrigger aria-label="Show items">
            <svg lucideChevronDown aria-hidden="true"></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No items found.</div>
        <div #scroller (scroll)="scrollTop.set(scroller.scrollTop)">
          <div uiComboboxList #list="uiComboboxList">
            <div [style.height.px]="list.state().items.length * row">
              @for (
                entry of visible(list.state().items);
                track entry.item.value
              ) {
                <div
                  uiComboboxItem
                  [value]="entry.item.value"
                  [label]="entry.item.label"
                  [index]="entry.index"
                  [style.top.px]="entry.index * row"
                  [style.height.px]="row"
                >
                  {{ entry.item.label }}
                </div>
              }
            </div>
          </div>
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly manyItems = manyItems
  readonly row = 32
  readonly height = 288
  readonly scrollTop = signal(0)
  readonly scroller = viewChild<ElementRef<HTMLDivElement>>("scroller")

  scrollToRow(highlight: ComboboxHighlight) {
    const el = this.scroller()?.nativeElement
    if (el && highlight.index >= 0) {
      el.scrollTop = scrollForRow(
        highlight.index,
        el.scrollTop,
        el.clientHeight,
        this.row
      )
    }
  }

  visible(items: readonly unknown[]) {
    const { start, end } = visibleRows(
      this.scrollTop(),
      this.height,
      items.length,
      this.row
    )
    return (items as Item[])
      .slice(start, end)
      .map((item, offset) => ({ item, index: start + offset }))
  }
}

export { Example }
Search 10,000 items or move through them with the arrow keys. Only the nearby rows render.

Controlled

The selection, text, and popup have separate values:

ValueChange notificationMeaning
value(beforeValueChange)One value or null; an array with multiple.
query(beforeQueryChange)The input’s text.
open(beforeOpenChange)Whether the popup is open.

Control only the values you need; value, query and open can also be bound with [(…)]. The before outputs include a reason and $event.cancel() to reject the request. Choosing an item writes its label into the input, and a canceled choice keeps the current one. Closing without choosing restores the value’s label unless custom values are allowed. State and Events covers the binding pattern.

While an input method composes text, like a Japanese conversion or a dead key's accent, the list keeps its filter and (beforeQueryChange) gets $event.composing: true. Search a server once it's false; async options wait for that on their own.

Focus leaving the input closes the popup with the reason focus-out, even when code moves it, like a notice that takes focus. To keep the popup open, cancel that close in (beforeOpenChange).

Console
import { Component, signal } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import { useLog } from "./log"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <div data-slot="stack">
      <div data-slot="controls">
        <button type="button" (click)="value.set('jp')">Choose Japan</button>
        <button type="button" (click)="open.set(true)">Open</button>
      </div>
      <ng-container
        uiCombobox
        [(value)]="value"
        [(query)]="query"
        [(open)]="open"
        [itemToLabel]="countryLabel"
        debug
        (beforeValueChange)="
          log('value: ' + $event.value + ' (' + $event.reason + ')')
        "
        (beforeQueryChange)="
          log('query: “' + $event.value + '” (' + $event.reason + ')')
        "
        (beforeOpenChange)="
          log('open: ' + $event.value + ' (' + $event.reason + ')')
        "
      >
        <div data-slot="stack">
          <label uiComboboxLabel>Country</label>
          <div data-slot="row">
            <input uiComboboxInput placeholder="Search countries…" />
            <button uiComboboxTrigger aria-label="Show countries">
              <svg lucideChevronDown></svg>
            </button>
          </div>
        </div>
        <div *uiComboboxContent>
          <div uiComboboxEmpty>No countries found.</div>
          <div uiComboboxList>
            @for (country of countries; track country.value) {
              <div
                uiComboboxItem
                [value]="country.value"
                [label]="country.label"
              >
                {{ country.label }}
                <span *uiComboboxItemIndicator>
                  <svg lucideCheck></svg>
                </span>
              </div>
            }
          </div>
        </div>
      </ng-container>
    </div>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina" },
    { value: "au", label: "Australia" },
    { value: "at", label: "Austria" },
    { value: "be", label: "Belgium" },
    { value: "br", label: "Brazil" },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark" },
    { value: "fi", label: "Finland" },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany" },
    { value: "gr", label: "Greece" },
    { value: "jp", label: "Japan" },
    { value: "nl", label: "Netherlands" },
    { value: "es", label: "Spain" },
    { value: "se", label: "Sweden" },
    { value: "ch", label: "Switzerland" },
  ]

  readonly countryLabel = (value: string) =>
    this.countries.find((country) => country.value === value)?.label ?? value

  readonly value = signal<string | null>("fr")

  readonly query = signal("France")

  readonly open = signal(false)

  readonly log = useLog()
}

export { Example }
Type, choose, or use the buttons. The console logs each value, query and open change with its reason.

Controller

Pass a controller from createComboboxController(). It can read or set the value and query, open or close the list, and focus the input. open() resolves when the list closes with its reason and source, including unmount; pass an abort signal to close it on cancellation. Controllers covers lifetime and setup.

Console
import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import { useLog } from "./log"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
  createComboboxController,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <div data-slot="stack">
      <div data-slot="controls">
        <button type="button" (click)="openAndWait()">Open and Wait</button>
        <button type="button" (click)="search()">Search “sw”</button>
        <button type="button" (click)="country.setValue('de')">
          Choose Germany
        </button>
        <button type="button" (click)="country.clear()">Clear</button>
      </div>
      <ng-container
        uiCombobox
        [controller]="country"
        [itemToLabel]="countryLabel"
      >
        <div data-slot="stack">
          <label uiComboboxLabel>Country</label>
          <div data-slot="row">
            <input uiComboboxInput placeholder="Search countries…" />
            <button uiComboboxTrigger aria-label="Show countries">
              <svg lucideChevronDown></svg>
            </button>
          </div>
        </div>
        <div *uiComboboxContent>
          <div uiComboboxEmpty>No countries found.</div>
          <div uiComboboxList>
            @for (item of countries; track item.value) {
              <div uiComboboxItem [value]="item.value" [label]="item.label">
                {{ item.label }}
                <span *uiComboboxItemIndicator>
                  <svg lucideCheck></svg>
                </span>
              </div>
            }
          </div>
        </div>
      </ng-container>
    </div>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina" },
    { value: "au", label: "Australia" },
    { value: "at", label: "Austria" },
    { value: "be", label: "Belgium" },
    { value: "br", label: "Brazil" },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark" },
    { value: "fi", label: "Finland" },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany" },
    { value: "gr", label: "Greece" },
    { value: "jp", label: "Japan" },
    { value: "nl", label: "Netherlands" },
    { value: "es", label: "Spain" },
    { value: "se", label: "Sweden" },
    { value: "ch", label: "Switzerland" },
  ]

  readonly countryLabel = (value: string) =>
    this.countries.find((country) => country.value === value)?.label ?? value

  readonly country = createComboboxController<string>()

  readonly log = useLog()

  async openAndWait() {
    const { reason } = await this.country.open()
    this.log(
      `Closed by ${reason}, with ${this.country.getValue() ?? "nothing"}`
    )
  }

  search() {
    this.country.focus()
    this.country.setQuery("sw")
    this.country.open()
  }
}

export { Example }
Use the buttons to drive the combobox from outside. Open and Wait logs how the list closed and what was chosen.

Positioning

side and align place the popup around the input or chips. anchor can use a different element, and uiComboboxArrow follows the side chosen after collision handling. Popups covers offsets and available space.

The page stays usable by default. modal="pointer" makes an outside press only dismiss the list; modal also locks scrolling and makes the rest of the page inert. The popup uses the top layer and renders in place; use container when its DOM belongs elsewhere, such as a shadow root.

import { Component, signal } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import { Checkbox, CheckboxIndicator } from "@ui-sdk/angular/checkbox"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxList,
} from "@ui-sdk/angular/combobox"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectItemIndicator,
  SelectLabel,
  SelectTrigger,
  SelectValue,
} from "@ui-sdk/angular/select"

type Side = "top" | "right" | "bottom" | "left"

type Align = "start" | "center" | "end"

@Component({
  imports: [
    Checkbox,
    CheckboxIndicator,
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxList,
    Select,
    SelectContent,
    SelectItem,
    SelectItemIndicator,
    SelectLabel,
    SelectTrigger,
    SelectValue,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <div data-slot="stack">
      <div data-slot="controls">
        <ng-container
          uiSelect
          [items]="sides"
          [value]="side()"
          (beforeValueChange)="$event.value && side.set($event.value)"
        >
          <div uiSelectLabel>Side</div>
          <button uiSelectTrigger>
            <span uiSelectValue></span>
            <svg lucideChevronDown></svg>
          </button>
          <div *uiSelectContent>
            @for (option of sides; track option.value) {
              <div uiSelectItem [value]="option.value">
                {{ option.label }}
                <span *uiSelectItemIndicator>
                  <svg lucideCheck></svg>
                </span>
              </div>
            }
          </div>
        </ng-container>
        <ng-container
          uiSelect
          [items]="aligns"
          [value]="align()"
          (beforeValueChange)="$event.value && align.set($event.value)"
        >
          <div uiSelectLabel>Align</div>
          <button uiSelectTrigger>
            <span uiSelectValue></span>
            <svg lucideChevronDown></svg>
          </button>
          <div *uiSelectContent>
            @for (option of aligns; track option.value) {
              <div uiSelectItem [value]="option.value">
                {{ option.label }}
                <span *uiSelectItemIndicator>
                  <svg lucideCheck></svg>
                </span>
              </div>
            }
          </div>
        </ng-container>
        <label data-slot="label">
          <button
            uiCheckbox
            [checked]="anchored()"
            (beforeCheckedChange)="anchored.set($event.value === true)"
          >
            <span uiCheckboxIndicator>
              <svg lucideCheck></svg>
            </span>
          </button>
          Anchor to the box
        </label>
      </div>
      <div #box data-slot="card">
        <ng-container uiCombobox>
          <input
            uiComboboxInput
            aria-label="Framework"
            placeholder="Framework"
          />
          <div
            *uiComboboxContent="{
              side: side(),
              align: align(),
              sideOffset: 10,
              alignOffset: 0,
              collisionPadding: 16,
              anchor: anchored() ? box : null,
            }"
          >
            <div uiComboboxEmpty>No frameworks found.</div>
            <div uiComboboxList>
              @for (framework of frameworks; track framework.value) {
                <div
                  uiComboboxItem
                  [value]="framework.value"
                  [label]="framework.label"
                >
                  {{ framework.label }}
                  <span *uiComboboxItemIndicator>
                    <svg lucideCheck></svg>
                  </span>
                </div>
              }
            </div>
          </div>
        </ng-container>
      </div>
    </div>
  `,
})
class Example {
  readonly frameworks = [
    { value: "next", label: "Next.js" },
    { value: "sveltekit", label: "SvelteKit" },
    { value: "nuxt", label: "Nuxt" },
    { value: "remix", label: "Remix" },
    { value: "astro", label: "Astro" },
    { value: "solidstart", label: "SolidStart" },
    { value: "qwik", label: "Qwik City" },
  ]

  readonly sides = [
    { value: "top", label: "Top" },
    { value: "right", label: "Right" },
    { value: "bottom", label: "Bottom" },
    { value: "left", label: "Left" },
  ]

  readonly aligns = [
    { value: "start", label: "Start" },
    { value: "center", label: "Center" },
    { value: "end", label: "End" },
  ]

  readonly side = signal<Side>("bottom")

  readonly align = signal<Align>("start")

  readonly anchored = signal(false)
}

export { Example }
Pick a side and an alignment, then open the list. Check Anchor to the Box to place it against the box instead of the input.

Animation

The content has data-starting-style while it opens and data-ending-style while it closes. Transition from those states, and the popup stays mounted until the exit finishes. (openChangeComplete) runs after opening or closing finishes, and keepMounted on an item indicator keeps it in the page for a selection animation.

[data-slot="combobox-content"] {
  transition:
    opacity 0.15s,
    translate 0.2s cubic-bezier(0.22, 1, 0.36, 1);

  &:is([data-starting-style], [data-ending-style]) {
    opacity: 0;
    translate: 0 -6px;
  }
}
Console
import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import { useLog } from "./log"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container
      uiCombobox
      (openChangeComplete)="
        log($event ? 'Finished opening' : 'Finished closing')
      "
    >
      <div data-slot="stack">
        <label uiComboboxLabel>Framework</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Select a framework" />
          <button uiComboboxTrigger aria-label="Show frameworks">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No frameworks found.</div>
        <div uiComboboxList>
          @for (framework of frameworks; track framework.value) {
            <div
              uiComboboxItem
              [value]="framework.value"
              [label]="framework.label"
            >
              {{ framework.label }}
              <span uiComboboxItemIndicator keepMounted>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly frameworks = [
    { value: "next", label: "Next.js" },
    { value: "sveltekit", label: "SvelteKit" },
    { value: "nuxt", label: "Nuxt" },
    { value: "remix", label: "Remix" },
    { value: "astro", label: "Astro" },
    { value: "solidstart", label: "SolidStart" },
    { value: "qwik", label: "Qwik City" },
  ]

  readonly log = useLog()
}

export { Example }
Open and close the list. The console logs when each animation finishes.

Presentation

Use presentation="sheet" for a sheet, or "auto" to choose a sheet on small touch screens each time the list opens. The input moves into the sheet’s header; there is still one input and one query.

A touch opening leaves the keyboard closed. Tapping the header input opens the keyboard and grows the sheet; closing the keyboard keeps the query. Choosing an item closes the sheet unless multiple is set. Swiping down closes it with the reason swipe.

Keep the options inside uiComboboxList so the header stays outside the listbox. Give sheet content a height, style it with data-presentation, and leave its translate for the sheet behavior. --sheet-backdrop controls the backdrop. The sheet is modal unless you set modal to false; mouse and keyboard openings keep input focus as it moves.

import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown } from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
  ],
  template: `
    <ng-container uiCombobox presentation="sheet">
      <div data-slot="stack">
        <label uiComboboxLabel>Framework</label>
        <div data-slot="row">
          <input uiComboboxInput placeholder="Select a framework" />
          <button uiComboboxTrigger aria-label="Show frameworks">
            <svg lucideChevronDown></svg>
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No frameworks found.</div>
        <div uiComboboxList>
          @for (framework of frameworks; track framework.value) {
            <div
              uiComboboxItem
              [value]="framework.value"
              [label]="framework.label"
            >
              {{ framework.label }}
              <span *uiComboboxItemIndicator>
                <svg lucideCheck></svg>
              </span>
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly frameworks = [
    { value: "next", label: "Next.js" },
    { value: "sveltekit", label: "SvelteKit" },
    { value: "nuxt", label: "Nuxt" },
    { value: "remix", label: "Remix" },
    { value: "astro", label: "Astro" },
    { value: "solidstart", label: "SolidStart" },
    { value: "qwik", label: "Qwik City" },
  ]
}

export { Example }
Open the field to see a sheet. On touch, tap the search field in its header to bring up the keyboard, or swipe down to close it.

Forms

A combobox submits the selected value under name, rather than the query text. Multiple values submit as separate entries. required prevents empty submissions, reset restores the default selection and its label, and form joins a form from elsewhere on the page.

The server HTML includes the hidden inputs for the selection, so their values can submit before hydration. Forms covers the shared integration.

In a Field, the field supplies the input's accessible name, description and error. Submitting a required field without a selection sets aria-invalid and data-invalid.

Console
import { Component } from "@angular/core"
import { LucideCheck, LucideChevronDown, LucideX } from "@lucide/angular"
import { useLog } from "./log"
import {
  Combobox,
  ComboboxChip,
  ComboboxChipRemove,
  ComboboxChips,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxItemIndicator,
  ComboboxList,
  ComboboxTrigger,
  ComboboxValue,
} from "@ui-sdk/angular/combobox"
import {
  Field,
  FieldDescription,
  FieldError,
  FieldLabel,
} from "@ui-sdk/angular/field"

@Component({
  imports: [
    Combobox,
    ComboboxChip,
    ComboboxChipRemove,
    ComboboxChips,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxItemIndicator,
    ComboboxList,
    ComboboxTrigger,
    ComboboxValue,
    Field,
    FieldDescription,
    FieldError,
    FieldLabel,
    LucideCheck,
    LucideChevronDown,
    LucideX,
  ],
  template: `
    <form data-slot="stack" (submit)="submit($event)">
      <div uiField name="country">
        <label uiFieldLabel>Country</label>
        <ng-container uiCombobox required [itemToLabel]="countryLabel">
          <div data-slot="row">
            <input uiComboboxInput placeholder="Search countries…" />
            <button uiComboboxTrigger aria-label="Show countries">
              <svg lucideChevronDown></svg>
            </button>
          </div>
          <div *uiComboboxContent>
            <div uiComboboxEmpty>No countries found.</div>
            <div uiComboboxList>
              @for (country of countries; track country.value) {
                <div
                  uiComboboxItem
                  [value]="country.value"
                  [label]="country.label"
                >
                  {{ country.label }}
                  <span *uiComboboxItemIndicator>
                    <svg lucideCheck></svg>
                  </span>
                </div>
              }
            </div>
          </div>
        </ng-container>
        <p uiFieldDescription>Where we ship your order.</p>
        <div>
          <div *uiFieldError="'valueMissing'">Choose a country.</div>
        </div>
      </div>
      <div uiField name="interests">
        <label uiFieldLabel>Interests</label>
        <ng-container uiCombobox multiple [defaultValue]="['Design']">
          <div uiComboboxChips>
            <span uiComboboxValue #comboboxValue="uiComboboxValue">
              @for (
                interest of itemsOf(comboboxValue.state().value);
                track interest
              ) {
                <div uiComboboxChip [value]="interest">
                  {{ interest }}
                  <button
                    uiComboboxChipRemove
                    [attr.aria-label]="\`Remove \${interest}\`"
                  >
                    <svg lucideX></svg>
                  </button>
                </div>
              }
            </span>
            <input uiComboboxInput placeholder="Add interests…" />
          </div>
          <div *uiComboboxContent>
            <div uiComboboxList>
              @for (interest of interests; track interest) {
                <div uiComboboxItem [value]="interest">
                  {{ interest }}
                  <span *uiComboboxItemIndicator>
                    <svg lucideCheck></svg>
                  </span>
                </div>
              }
            </div>
          </div>
        </ng-container>
      </div>
      <div data-slot="row">
        <button type="submit">Submit</button>
        <button type="reset">Reset</button>
      </div>
    </form>
  `,
})
class Example {
  readonly countries = [
    { value: "ar", label: "Argentina" },
    { value: "au", label: "Australia" },
    { value: "at", label: "Austria" },
    { value: "be", label: "Belgium" },
    { value: "br", label: "Brazil" },
    { value: "ca", label: "Canada" },
    { value: "cl", label: "Chile" },
    { value: "dk", label: "Denmark" },
    { value: "fi", label: "Finland" },
    { value: "fr", label: "France" },
    { value: "de", label: "Germany" },
    { value: "gr", label: "Greece" },
    { value: "jp", label: "Japan" },
    { value: "nl", label: "Netherlands" },
    { value: "es", label: "Spain" },
    { value: "se", label: "Sweden" },
    { value: "ch", label: "Switzerland" },
  ]

  readonly countryLabel = (value: string) =>
    this.countries.find((country) => country.value === value)?.label ?? value

  readonly interests = [
    "Design",
    "Engineering",
    "Marketing",
    "Research",
    "Sales",
  ]

  readonly log = useLog()

  submit(event: SubmitEvent) {
    event.preventDefault()
    const entries = [
      ...new FormData(event.currentTarget as HTMLFormElement),
    ].map(([name, value]) => `${name}=${value}`)
    this.log(`Submitted ${entries.join("&")}`)
  }

  itemsOf(items: unknown) {
    return items as string[]
  }
}

export { Example }
Submit without a country to see the inline error. Choose one and submit; the console logs the values, and Reset restores the defaults.

Custom Rendering

Each directive goes on an element you write. Read a part's state from a template reference, like #trigger="uiComboboxTrigger" and then trigger.state().open, and the content's from *uiComboboxContent="let content". Each part's state is listed below.

import { Component } from "@angular/core"
import {
  LucideCheck,
  LucideChevronDown,
  LucideChevronUp,
  LucideSearch,
} from "@lucide/angular"
import {
  Combobox,
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxLabel,
  ComboboxList,
  ComboboxTrigger,
} from "@ui-sdk/angular/combobox"

@Component({
  imports: [
    Combobox,
    ComboboxContent,
    ComboboxEmpty,
    ComboboxInput,
    ComboboxItem,
    ComboboxLabel,
    ComboboxList,
    ComboboxTrigger,
    LucideCheck,
    LucideChevronDown,
    LucideChevronUp,
    LucideSearch,
  ],
  template: `
    <ng-container uiCombobox>
      <div data-slot="stack">
        <label uiComboboxLabel>Assignee</label>
        <div data-slot="row">
          <div data-slot="row">
            <svg lucideSearch></svg>
            <input uiComboboxInput placeholder="Search people…" />
          </div>
          <button
            uiComboboxTrigger
            #comboboxTrigger="uiComboboxTrigger"
            aria-label="Show people"
          >
            @if (comboboxTrigger.state().open) {
              <svg lucideChevronUp></svg>
            } @else {
              <svg lucideChevronDown></svg>
            }
          </button>
        </div>
      </div>
      <div *uiComboboxContent>
        <div uiComboboxEmpty>No one by that name.</div>
        <div uiComboboxList>
          @for (user of users; track user.id) {
            <div
              uiComboboxItem
              #comboboxItem="uiComboboxItem"
              [value]="user.username"
              [label]="user.name"
              [keywords]="[user.username]"
            >
              <span data-slot="badge">{{ user.name.slice(0, 1) }}</span>
              <span data-slot="stack">
                {{ user.name }}
                <span data-slot="hint">@{{ user.username }}</span>
              </span>
              @if (comboboxItem.state().selected) {
                <svg lucideCheck></svg>
              } @else if (comboboxItem.state().highlighted) {
                <kbd data-slot="kbd">Enter</kbd>
              }
            </div>
          }
        </div>
      </div>
    </ng-container>
  `,
})
class Example {
  readonly users = [
    { id: 1, name: "Hollis Grant", username: "hollis", role: "Owner" },
    { id: 2, name: "Inès Moreau", username: "ines", role: "Admin" },
    { id: 3, name: "Kofi Mensah", username: "kofi", role: "Member" },
    { id: 4, name: "Wren Takahashi", username: "wren", role: "Member" },
    { id: 5, name: "Tomasz Wójcik", username: "tomasz", role: "Guest" },
  ]
}

export { Example }
Open the list and move through it. The chevron flips while it's open, the highlighted person shows Enter, and the chosen one shows a check.

Styling

Each part has a data-slot, such as combobox-content, and shows its state through the attributes listed under Data Attributes.

Use data-highlighted for the active option and data-selected for chosen values. Because the keyboard highlight usually moves without focus leaving the input, use the content's data-modality="keyboard" to style it. Real focus can move into the list for touch screen readers or into the sheet.

--anchor-width follows the input or chips. --available-height doesn't inherit: when a nested scroller needs it, copy it to a custom property on the content, such as --list-height: var(--available-height), then use that property on the scroller.

ComboboxContent

VariableWhat it holds
--anchor-widthWidth of the anchor, usually the trigger. Use it to match widths.
--anchor-heightHeight of the anchor.
--available-widthSpace beside the popup, up to the viewport edge. Not inherited either.
--available-heightSpace between the anchor and the viewport edge. Use it for max-height. Not inherited, so a child that needs it copies it on the popup, like [--list-height:var(--available-height)], and reads max-h-(--list-height). The first popup registers both names for the whole page with CSS.registerProperty, so they don't inherit anywhere. A page that needs them to inherit calls it first, with inherits: true. An @property rule can't, since a registration in script wins.
--transform-originThe point on the anchor the popup opens from. Use it to scale from the right place.
--arrow-offsetWhere the anchor's center falls along the popup's edge, kept arrowPadding from the corners. Position a ::before arrow with it.
--drawer-progressWhile it presents as a sheet: how far open the sheet is, from 0 closed to 1 at its largest snap point. Never past 1.
--drawer-dimWhile it presents as a sheet: how dim the page behind is, from 0 to 1. The backdrop's opacity follows it.
--drawer-expandWhile it presents as a sheet: 0 at the second-largest snap point and below, 1 at the largest. With one snap point, the whole travel.
--drawer-stackWhile it presents as a sheet: how many sheets opened from inside this one are open above it, rising smoothly as each one opens. Push it back with it.
--sheet-backdropSet it yourself: the color the page dims to while it presents as a sheet. Black at 0.2 by default.

Viewport

VariableWhat it holds
--keyboard-insetWhile it presents as a sheet: how many pixels of the page the on-screen keyboard covers, 0 without one.
--visual-viewport-widthWhile it presents as a sheet: the width of the part of the page you can see.
--visual-viewport-heightWhile it presents as a sheet: the height of the part of the page you can see, above the keyboard.
--visual-viewport-topWhile it presents as a sheet: how far the part of the page you can see is scrolled from the top of the layout, as when the keyboard pushes it up.

Data Attributes

ComboboxLabel

[data-slot="combobox-label"]

AttributeWhat it means
data-disabledPresent when the combobox is disabled, by its own prop, a field or a <fieldset>.
data-readonlyPresent when the combobox is read-only.
data-requiredPresent when the combobox is required.

ComboboxInput

[data-slot="combobox-input"]

AttributeWhat it means
data-closedPresent while the list is closed, including while it animates out.
data-openPresent while the list is open.
data-disabledPresent when the combobox is disabled, by its own prop, a field or a <fieldset>.
data-readonlyPresent when the combobox is read-only.
data-requiredPresent when the combobox is required.

ComboboxTrigger

[data-slot="combobox-trigger"]

AttributeWhat it means
data-closedPresent while the list is closed, including while it animates out.
data-openPresent while the list is open.
data-disabledPresent when the combobox is disabled, by its own prop, a field or a <fieldset>.
data-readonlyPresent when the combobox is read-only.
data-requiredPresent when the combobox is required.

ComboboxClear

[data-slot="combobox-clear"]

AttributeWhat it means
data-disabledPresent when the combobox is disabled or read-only.

ComboboxChips

[data-slot="combobox-chips"]

AttributeWhat it means
data-disabledPresent when the combobox is disabled, by its own prop, a field or a <fieldset>.
data-readonlyPresent when the combobox is read-only.
data-requiredPresent when the combobox is required.

ComboboxContent

[data-slot="combobox-content"]

AttributeWhat it means
data-closedPresent while the list is closed, including while it animates out.
data-presentationpopoversheetHow the list presents this time it's open.
data-openPresent while the list is open.
data-starting-stylePresent for the first frame. Style the state you animate from.
data-ending-stylePresent while the list animates out. Style the state you animate to.
data-sidetoprightbottomleftWhere the list ended up, after flipping away from edges.
data-alignstartcenterendHow the list lines up with the input.
data-modalitykeyboardpointerWhether the keyboard or a pointer moves the highlight. Style a focus ring for the keyboard only.
data-has-iconsPresent while any item inside holds an icon part, so items without one can line up.

ComboboxItem

[data-slot="combobox-item"]

AttributeWhat it means
data-selectedPresent on selected items, and on the check inside them.
data-disabledPresent when the item can't be chosen, or maxSelected is reached.
data-highlightedPresent on the highlighted item. Focus stays in the input.
data-has-iconPresent on an item while it holds an icon part.

ComboboxItemText

[data-slot="combobox-item-text"]

AttributeWhat it means
data-matchedPresent on an item's text while the input's text matched part of it, which is marked.

ComboboxItemIndicator

[data-slot="combobox-item-indicator"]

AttributeWhat it means
data-selectedPresent on selected items, and on the check inside them.

ComboboxEmpty

[data-slot="combobox-empty"]

AttributeWhat it means
data-loadingPresent while results load, with status="loading".
data-emptyPresent while no item matches.

ComboboxStatus

[data-slot="combobox-status"]

AttributeWhat it means
data-loadingPresent while results load, with status="loading".

ComboboxArrow

[data-slot="combobox-arrow"]

AttributeWhat it means
data-closedPresent while the list is closed, including while it animates out.
data-openPresent while the list is open.
data-sidetoprightbottomleftWhere the list ended up, after flipping away from edges.
data-alignstartcenterendHow the list lines up with the input.
data-arrow-clampedPresent on the arrow when it stops short of the middle of the input, held back by arrowPadding.

ComboboxItemIcon

[data-slot="combobox-item-icon"]

AttributeWhat it means
data-mirrorPresent on an icon that flips in right-to-left text, with mirror.

ComboboxChip

[data-slot="combobox-chip"]

AttributeWhat it means
data-valueaThe chip's value, as the string it submits as.
data-disabledPresent when the combobox is disabled or read-only, so the chip can't be removed.

ComboboxChipRemove

[data-slot="combobox-chip-remove"]

AttributeWhat it means
data-disabledPresent when the combobox is disabled or read-only.

ComboboxSelectAll

[data-slot="combobox-select-all"]

AttributeWhat it means
data-disabledPresent when nothing the select-all option covers can be chosen, or choosing them all would pass maxSelected.
data-uncheckedPresent on a select-all option while none of its items is selected.
data-highlightedPresent on the highlighted item. Focus stays in the input.

ComboboxCreate

[data-slot="combobox-create"]

AttributeWhat it means
data-highlightedPresent while the create option is highlighted.
data-pendingPresent while the Promise onCreate returned is running.

API Reference

Each option below is an input on the directive, and each callback an output. A change callback is two outputs: (beforeValueChange), with the details and cancel(), then (valueChange) with the new value alone. value, query and open can be bound with [(…)].

Combobox

container?DocumentFragment | Element | null
Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
query?string
The input's text, which filters the list. Pass it to control it. Choosing an item sets it to the item's label, or empties it with multiple.
defaultQuery?string
The input's text at first, when uncontrolled. Defaults to the selected item's label.
(beforeQueryChange)
Runs when the input's text wants to change: typing, choosing an item, or closing with text that wasn't chosen. While an input method composes, details.composing is true; search once it's false.
open?boolean
Whether the list is open. Pass it to control it.
defaultOpen?boolean
Whether the list starts open, when uncontrolled.
(beforeOpenChange)
Runs when the list wants to open or close. details.reason says why, and details.cancel() stops it.
(openChangeComplete)
Runs once the list has finished opening or closing, after any animation.
maxSelected?number
With multiple, how many items can be selected. Once reached, the other items are disabled.
items?ListData<T>
The items as data. Renders the list for you, and filters it without rendering every item.
emptyItems?ListData<T>
Items shown instead of items while the input is empty, like recent choices or suggestions. Groups work, like { type: "group", label: "Recent", items }. Needs items.
filter?ListFilter<T>
How typing narrows the list: "contains", "startsWith", a function of the item and the text, whose numeric result also sorts data items, or false to keep every item, for results a server already filtered.
itemToValue?((value: T) => string)
The string an item's value submits as and is identified by, for object values. Strings pass through, and objects use their value or id.
itemToLabel?((value: T) => string)
The text a value shows, for values whose item isn't rendered, like async results.
isItemEqualToValue?((itemValue: T, value: T) => boolean)
Whether an item's value is the selected value, for object values that aren't the same object.
autoHighlight?"always" | "selected" | boolean
Whether the first matching item is highlighted while typing, so Enter chooses it. "always" also highlights the selected item, or the first, when the list opens, so arrows move from there. "selected" highlights only the selected item when the list opens, and nothing when none is.
keepQuery?boolean
With multiple, whether the input keeps its text after an item is chosen.
pendingAnnouncement?string
What screen readers hear once the Create part's (create) has been pending for a second, so a slow action doesn't pass in silence. Set it in the page's language. An empty string says nothing.
allowCustomValue?boolean
Whether text that matches no item becomes the value, when Enter is pressed with nothing highlighted, or, without multiple, when the list closes. The value is the text itself.
status?AsyncOptionsStatus
Whether results are loading or failed, for the status and empty parts. Sets aria-busy on the list while loading.
(highlight)
Runs when the highlight moves, with the item's index among the visible items, so a virtualized list can scroll to it.
(loadMore)
Runs when the highlight or scrolling reaches the last item, so the next page can load, like createAsyncOptions's loadMore. Not again for the same items, unless the last load failed.
announcement?((change: ListAnnouncement) => string | null | undefined)
What screen readers hear after typing pauses, when no ComboboxStatus is rendered, and when a chip is removed. Return null for nothing.
loop?boolean
Whether arrow keys wrap from the last item to the first.
modal?"pointer" | boolean
false: the page stays usable while the list is open. "pointer": an outside press only closes the list. true: also locks scroll and makes the rest of the page inert.
presentation?PresentationSetting<"popover">
How the list presents. "sheet" slides it up from the bottom of the screen with the input in its header, where it can be swiped away, and "auto" does that on small touch screens. A tap that opens a sheet leaves the keyboard closed until the input in the header is tapped. Decided each time it opens; the server renders "popover" for "auto".
disabled?boolean
Disables the combobox like a native input: it can't be focused or changed, and the value isn't submitted.
readOnly?boolean
Keeps the combobox focusable and its value submitted, but stops changes.
required?boolean
Blocks form submission until a value is selected, with the browser's own message.
name?string
The name the value submits under. Without one, the combobox submits nothing.
form?string
The id of a form to belong to, when the combobox isn't inside that form.
controller?object
Opens, closes, reads and sets the combobox from anywhere. Create one with createComboboxController().
dismissible?boolean
Whether Escape, an outside press, focus or the window leaving, Android's back gesture and a sheet's swipe can close it. Triggers, Close parts and the controller always can. Pass false while it holds unsaved work, and ask in (dismissAttempt).
(dismissAttempt)
Runs when dismissible refused a dismissal made on purpose: Escape, an outside press, back or a swipe. Focus or the window leaving is refused without it. Ask "Discard changes?" here.
debug?boolean
Logs every state change with its reason to the console, in development builds.
multiple?boolean
Whether several items can be selected. The value is then a list, the list stays open as items toggle, and the input empties after each choice. Whether several items can be selected.
value?T | T[] | null
The selected value. Pass it to control the combobox. null selects nothing. The selected values. Pass it to control the combobox. The selected value, or values with multiple. Pass it to control the combobox.
defaultValue?T | T[] | null
The value selected at first, when uncontrolled. A form reset returns to it. The values selected at first, when uncontrolled. A form reset returns to them. The value or values selected at first, when uncontrolled. A form reset returns to it.
(beforeValueChange)
Runs when a user, a form reset or a controller wants to change the value. details.reason says why, and details.cancel() stops it.

announcement receives { type: "results", count, query, loading } or { type: "removed", label } and returns the words, or null for silence. The default is English: "3 results", "No results", "Loading" or "France removed".

ComboboxLabel

The input's visible label. Goes on a label.

ComboboxInput

The text field that filters the list and shows the chosen label. Goes on a input.

ComboboxTrigger

Opens and closes the list. Renders a button, kept out of the tab order while the input sits beside it.

ComboboxClear

keepMounted?boolean
Whether the clear button stays in the page while there's nothing to clear.

ComboboxChips

Holds the chips and the input for a multiple selection. Goes on a div.

ComboboxValue

maxLabels?number
With multiple, how many labels the label in its state shows before the rest are counted, as in "France, Chile and 2 more", joined the way the page's language joins lists, or in English with the default getMoreLabel.
getMoreLabel?((count: number) => string)
The words for the labels past maxLabels.

ComboboxChip

valueT
The selected value this chip shows.

ComboboxChipRemove

Removes its chip's value. Goes on a button. Takes the same inputs as uiComboboxChip.

ComboboxChipsOverflow

Turns collapsing on for the chips around it, and shows how many are hidden. Goes on a span.

ComboboxValueIcon

Shows the selected item's icon beside the input. It takes no inputs of its own, and you leave it empty.

ComboboxContent

side?Side
Which side of the anchor the popup opens on. Flips to the other side when there isn't room. Which side of the input the list opens on.
align?Align
How the popup lines up with the anchor along that side. start and end follow the reading direction. How the list lines up with the input along that side.
sideOffset?number
Gap between the anchor and the popup, in pixels. Gap between the input and the list, in pixels.
alignOffset?number
Shift along the anchor, in pixels. Shift along the input, in pixels.
collisionPadding?number
Space to keep from the viewport edges, in pixels.
arrowPadding?number
Space to keep between the arrow and the popup's corners, in pixels.
anchor?string | Anchor | null
Positions the popup against this instead of its trigger: an element, a CSS selector, a point like { x, y }, or anything with getBoundingClientRect(). It's read on every check, so it can move. A controller's open({ anchor }) wins for that open.
container?DocumentFragment | Element | null
Renders the popup into this element instead of in place, like a container inside a shadow root or an iframe. On web components, a CSS selector. Nested popups stay inside their parent.
keepMounted?boolean
Whether the list stays in the page, hidden, while closed.

ComboboxArrow

Points from the popup to its anchor, following the side chosen after collision handling. Goes on a div.

ComboboxStatus

Announces loading, errors and result counts. Gets the status role.

ComboboxEmpty

Shows while no option matches, and screen readers read it when it appears. Goes on a div, which gets the status role.

ComboboxList

Holds the options. Gets the listbox role.

ComboboxSelectAll

Toggles every matching, enabled option in its group, or outside a group. Gets the option role.

ComboboxGroup

Groups options under a label. Gets the group role.

ComboboxGroupLabel

Names its group. Goes on a div.

ComboboxItem

label?string
The text the input shows once chosen, and filtering matches, when the content isn't plain text. Not the accessible name: use aria-label for that.
keywords?string[]
More words filtering matches.
disabled?boolean
Keeps the item from being chosen. The keyboard and the pointer skip it. Sets data-disabled and aria-disabled.
index?number
The item's position among all visible items, for virtualized lists that render only some. Sets aria-posinset and aria-setsize.
valueT
What the value becomes when the item is chosen. A string, or any value with itemToValue.

ComboboxItemIcon

mirror?boolean
Flips the icon horizontally in right-to-left text, for icons that point a way, like arrows and chevrons. Icons that picture a thing, like a clock or a check, stay as they are.

ComboboxItemText

Shows its item's label, and marks what matched the query. Goes on a span.

ComboboxItemIndicator

keepMounted?boolean
Whether the indicator stays in the page while its item isn't selected.

ComboboxSeparator

Separates options or groups. Gets the separator role.

ComboboxCreate

(create)
Runs with the input's text when the create option is chosen. It doesn't change the value by itself. Return a Promise to mark the option pending until it settles; the list closes (or the input empties, with multiple) once it resolves.
minLength?number
How many characters the text needs before the option shows.

Items as Data

Each item in items. Groups are { type: "group", label, items } and separators { type: "separator" }.

valueT
Identifies the item, and is what choosing it reports. A string, or any value with itemToValue.
labelstring
The text shown and matched by typeahead and filtering. A select's trigger shows it once chosen.
keywords?string[]
More words filtering matches, like ["team"] for a plan called Pro.
disabled?boolean
Keeps the item from being chosen. The keyboard skips it, like in a native select.

Async Options

Async Options covers loading, paging, and retries.

State

What each part's state() signal holds, per part.

uiComboboxInput:

openboolean
Whether the list is open.
disabledboolean
Whether the combobox is disabled, by itself or by a <fieldset>.
readOnlyboolean
Whether the combobox keeps its value but refuses changes, from its readOnly option.
requiredboolean
Whether a value must be selected before the form submits, from its required option.

uiComboboxTrigger:

openboolean
Whether the list is open.
disabledboolean
Whether the combobox is disabled, by itself or by a <fieldset>.
readOnlyboolean
Whether the combobox keeps its value but refuses changes, from its readOnly option.
requiredboolean
Whether a value must be selected before the form submits, from its required option.

uiComboboxContent and uiComboboxList:

openboolean
Whether the list is open. False while it animates out.
presentation"popover" | "sheet"
How it presents this time it's open.
multipleboolean | undefined
Whether several items can be selected.
statusAsyncOptionsStatus
Whether results are loading or failed.
itemsListData<unknown>
The visible items, for rendering a virtualized list yourself.

uiComboboxItem:

highlightedboolean
Whether the item is highlighted, by the keyboard or the pointer.
selectedboolean
Whether its value is in the combobox's value, compared with isItemEqualToValue when you pass one.
disabledboolean
Whether the item can't be chosen, by itself or because maxSelected is reached.
maxReachedboolean
Whether maxSelected is reached and the item isn't selected, which is why it's disabled.

uiComboboxItemIndicator:

selectedboolean
Whether its item is selected. While false, the indicator isn't shown unless keepMounted is set.

uiComboboxItemIcon:

mirrorboolean
Whether it flips in right-to-left text.

uiComboboxCreate:

querystring
The text the option would create.
highlightedboolean
Whether the option is highlighted.
pendingboolean
Whether onCreate's Promise is running.
errorunknown
Why the last onCreate failed, until the next try.

uiComboboxEmpty:

loadingboolean
Whether results are loading.
emptyboolean
Whether no item matches.
querystring
The text the list is filtered by.

uiComboboxStatus:

status"idle" | "loading" | "error"
Whether results are loading or failed.
loadingboolean
Whether results are loading.
countnumber
How many items are visible.

uiComboboxValue:

valueunknown
The selected value: one, null, or a list with multiple.
labelsstring[]
Each selected item's label, in the order they were selected.
labelstring
The labels joined with commas, or with maxLabels, as a list in the page's language, like "France, Chile and 2 more". An empty string for none.

uiComboboxChip:

valueunknown
The selected value the chip stands for, from its value prop.
labelstring
The text for the value: from itemToLabel, its item's label, or the value itself.
disabledboolean
Whether the combobox is disabled or read-only, so the chip can't be removed.

uiComboboxClear and uiComboboxChipRemove:

disabledboolean
Whether the combobox is disabled or read-only.

uiComboboxArrow:

openboolean
Whether the list is open.

uiComboboxItemText:

segmentsMatchSegment[]
The text in pieces, each marked when it matched. Joined, they're the whole text.
matchedboolean
Whether any piece matched.

uiComboboxSelectAll:

checkedboolean
Whether every item it covers is selected.
indeterminateboolean
Whether some of its items are selected, but not all.
highlightedboolean
Whether it's highlighted, by the keyboard or the pointer.
disabledboolean
Whether it can't be used: nothing it covers can be chosen, or choosing them all would pass maxSelected.

uiComboboxChipsOverflow:

countnumber
How many chips don't fit and are hidden.
labelsstring[]
The labels of the hidden chips.

Reasons

$event.reason says why the value changed:

item-pressMouseEvent | KeyboardEvent
A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
input-changeEvent
Typing, pasting or dropping changed a text field's value; in a combobox it can also open or close it, or Enter keeps the typed text as the value.
clear-pressMouseEvent | KeyboardEvent
A Clear part was pressed, like on an input, a select or a combobox.
remove-pressMouseEvent | KeyboardEvent
A chip's remove part was pressed, or Backspace or Delete removed a chip or a span.
escape-keyKeyboardEvent
Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
resetnone
A form reset.
restorenone
The browser restored state, like after going back, or a saved value was read back from storage.
imperativenone
A controller or api call.

Why the text changed:

item-pressMouseEvent | KeyboardEvent
A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
input-changeEvent
Typing, pasting or dropping changed a text field's value; in a combobox it can also open or close it, or Enter keeps the typed text as the value.
clear-pressMouseEvent | KeyboardEvent
A Clear part was pressed, like on an input, a select or a combobox.
escape-keyKeyboardEvent
Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
resetnone
A form reset.
imperativenone
A controller or api call.
trigger-pressMouseEvent | KeyboardEvent | TouchEvent
Click, tap, Enter or Space on the part that opens, closes or toggles. Arrow keys that open a menu or submenu count too. A tap on a combobox's input that opens a sheet reports its touchend.
close-pressMouseEvent | KeyboardEvent | SubmitEvent
A Close part was pressed, or a form with method="dialog" was submitted.
outside-pressMouseEvent
A press outside the layer.
focus-outKeyboardEvent | FocusEvent
Focus left the layer, or Tab moved it out.
window-blurFocusEvent
The window lost focus.
backEvent
Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
swipeTouchEvent | PointerEvent
A swipe gesture: a finger, mouse or pen dragged it.
anchor-hiddennone
The element the popup sits beside stopped rendering, like a trigger a breakpoint hides.

And why the list opened or closed:

item-pressMouseEvent | KeyboardEvent
A member of a collection was chosen: a menu item, a tab, a radio or a checkbox item.
input-changeEvent
Typing, pasting or dropping changed a text field's value; in a combobox it can also open or close it, or Enter keeps the typed text as the value.
escape-keyKeyboardEvent
Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
imperativenone
A controller or api call.
trigger-pressMouseEvent | KeyboardEvent | TouchEvent
Click, tap, Enter or Space on the part that opens, closes or toggles. Arrow keys that open a menu or submenu count too. A tap on a combobox's input that opens a sheet reports its touchend.
close-pressMouseEvent | KeyboardEvent | SubmitEvent
A Close part was pressed, or a form with method="dialog" was submitted.
outside-pressMouseEvent
A press outside the layer.
focus-outKeyboardEvent | FocusEvent
Focus left the layer, or Tab moved it out.
window-blurFocusEvent
The window lost focus.
backEvent
Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
swipeTouchEvent | PointerEvent
A swipe gesture: a finger, mouse or pen dragged it.
anchor-hiddennone
The element the popup sits beside stopped rendering, like a trigger a breakpoint hides.

With dismissible false, the refused dismissals (dismissAttempt) reports:

escape-keyKeyboardEvent
Escape, or a submenu's close key (ArrowLeft in left-to-right layouts).
outside-pressMouseEvent
A press outside the layer.
backEvent
Going back: the Android back button or gesture, or Backspace in an empty command input, which returns to the previous page.
swipeTouchEvent | PointerEvent
A swipe gesture: a finger, mouse or pen dragged it.

Controller

Create one with createComboboxController<Value, Multiple>() and pass it as controller.

Every write method takes an optional { reason, event }, passed to the change outputs.

isOpen()() => boolean
Whether the list is open.
setOpen(open, options?)(open: boolean, options?: ComboboxChangeOptions<ComboboxOpenChangeReason> | undefined) => boolean
Opens or closes the list. Returns false when the change was canceled or it was already open or closed.
open(options?)(options?: (ComboboxChangeOptions<ComboboxOpenChangeReason> & { signal?: AbortSignal | undefined; }) | undefined) => Promise<...>
Opens the list, and resolves once it closes, with why and how. Resolves exactly once and never rejects: on the next close from any source, when signal aborts, or with reason "unmount" when the combobox leaves the page.
close(options?)(options?: ComboboxChangeOptions<ComboboxOpenChangeReason> | undefined) => boolean
Closes the list. Returns false when the close was canceled or it was already closed.
toggle(options?)(options?: ComboboxChangeOptions<ComboboxOpenChangeReason> | undefined) => boolean
Opens the list when it's closed, and closes it when it's open. Returns false when the change was canceled.
getValue()() => ComboboxValue<T, Multiple>
The selected value.
setValue(value, options?)(value: ComboboxValue<T, Multiple>, options?: ComboboxChangeOptions<ComboboxValueChangeReason> | undefined) => boolean
Selects a value, as a user would. A disabled or read-only combobox ignores it. Returns false when the change was canceled or nothing changed.
clear(options?)(options?: ComboboxChangeOptions<ComboboxValueChangeReason> | undefined) => boolean
Selects nothing and empties the input. Returns false when the change was canceled or nothing changed.
getQuery()() => string
The input's text.
setQuery(query, options?)(query: string, options?: ComboboxChangeOptions<ComboboxQueryChangeReason> | undefined) => boolean
Changes the input's text, which filters the list. Returns false when the change was canceled or nothing changed.
getHighlighted()() => T | null
The value of the highlighted item, or null when none is.
highlight(value)(value: T | null) => boolean
Highlights the item with this value in the open list, scrolled into view, or none with null. Returns false when the list is closed, or no enabled item has the value.
focus()() => void
Moves focus to the input.

Events

A before output emits { value, reason, event, cancel() } before the change, and its plain output follows with the value alone. A bound value only updates when the change isn't canceled.

BindingOnReceives
[(value)]uiComboboxThe selected value
[(query)]uiComboboxThe input's text
[(open)]uiComboboxWhether the list is open
(beforeValueChange)uiCombobox{ value, reason, cancel() }: the new value, and the reason
(beforeQueryChange)uiCombobox{ value, reason, cancel() }: the new text, the reason and whether it's still composing
(beforeOpenChange)uiCombobox{ value, reason, cancel() }: the new state, and the reason
(openChangeComplete)uiCombobox$event, whether it's open, after the animation
(highlight)uiCombobox{ value, index, event }: the highlighted item and its row
(loadMore)uiCombobox(), when the last item is reached
(dismissAttempt)uiCombobox{ reason, event }, when a dismissal was refused
(create)uiComboboxCreate{ query, waitUntil() }: the text. waitUntil(promise) marks it pending

Accessibility

The combobox follows the WAI-ARIA combobox pattern with list autocomplete. Focus usually stays in the input while aria-activedescendant identifies the highlighted option. A touch screen-reader trigger can move real focus into the list, and a sheet has its own focus behavior. Every line below is an automated test.

Keyboard

KeyDoes
TypingFilters the options and opens the list
ArrowDown, ArrowUpOpens the list, then moves the highlight. Wraps unless [loop]="false"
EnterChooses the highlighted option
EscapeCloses the list, then restores the selection's label
BackspaceIn an empty input with chips, removes the last chip
ArrowLeft, ArrowRightMoves between chips, reversed in right-to-left text

Tested Behavior

Input
  • Is a combobox named by its label, with list autocomplete.
  • Typing opens the list with the items that match.
  • Text an input method is composing filters once it's committed.
  • Matching ignores case and accents.
  • ArrowDown opens the list.
  • Choosing with the keyboard leaves the caret after the text.
  • Points to the list it controls while open.
Highlight
  • Arrow keys move the highlight while focus stays in the input.
  • Arrow keys skip disabled items.
  • Moving over a disabled item leaves the highlight where it was.
  • The highlighted option has the id aria-activedescendant names.
AutoHighlight
  • The first match is highlighted from the first keystroke, so Enter chooses it.
  • A disabled match is passed over.
Choosing
  • Enter chooses the highlighted item, puts its label in the input and closes.
  • Clicking an item chooses it and keeps focus in the input.
  • A disabled item can't be chosen.
  • After choosing, opening again shows every item with the chosen one selected.
  • A canceled choice closes the list and keeps the value's label in the input.
  • Text that matches nothing shows the empty message.
Closing
  • Escape closes the list and keeps focus in the input.
  • Escape after deleting the text brings back the value and its label.
  • Leaving after deleting the text keeps the value empty.
  • Clicking outside closes the list.
  • Tab closes the list and moves on.
Trigger and clear
  • The trigger button opens and closes the list.
  • Clear empties the input and the value.
Default value
  • Shows its label in the input.
  • Typing inside the label keeps the caret where it is.
Multiple
  • Choosing adds a chip and empties the input.
  • A canceled choice adds no chip and keeps the text.
  • Backspace in an empty input removes the last chip.
  • A chip's remove button removes its value.
Groups
  • Items sit in groups named by their labels, and empty groups hide while filtering.
Forms
  • The form submits the value under the combobox's name.
  • Several values submit under one name.
  • A required combobox blocks submission until a value is chosen.
  • A disabled combobox can't be focused.
  • A disabled fieldset disables the combobox and leaves it out of the form.
Async
  • Results load for the text, with the list kept while loading.
  • The chosen item's label survives results that don't include it.

Runs in React, Vue and web components.

Long lists stay fast and announce their size:

Virtualized
  • Renders only the rows in view, each with its place in the whole list.
  • Arrow keys reach items that weren't rendered, and the active descendant follows.
  • Filtering covers every item, rendered or not.

Runs in React.

Also tested:

Enhancements
  • The list is named by the combobox's label.
  • A click on the label focuses the input and leaves the list closed.
  • Filtering matches an item's keywords as well as its label.
  • A create option offers the text, and hides when an item's label matches it exactly.
  • Enter on the create option calls onCreate with the text.
  • A create option is pending while onCreate's Promise runs.
  • With multiple, the list stays open after choosing.
  • MaxSelected disables the other items once reached.
  • Arrow keys move between chips, and Backspace on one removes it.
  • The chips are a toolbar named by the combobox's label.
  • Web chips follow a label that changes after they rendered. Web components only.
  • Enter on the trigger opens the list as the keyboard did.
  • ArrowDown on the trigger opens the list at its first item.
  • The content says whether the keyboard or a pointer is in use, while focus stays in the input.
  • A form reset returns the combobox to its default value and label.
  • Arrow keys keep the highlighted item in view when the … scrolls.

Runs in React, Vue and web components.

Rows people rebuild, here and in Select:

Items shown while nothing is typed
  • A combobox shows its recent items, as a group, until the user types.
  • An autocomplete shows recent searches while the field is empty.
Select all
  • Selects every item that can be chosen, then clears them, and says which with aria-checked.
  • Is mixed while some are selected.
  • Covers only the items the text matches.
  • Is reached with the arrow keys and chosen with Enter.
  • In a group, it covers that group.
  • A select's works the same, with real focus.
Chips that collapse
  • Chips past the line hide, and a count says how many.
  • Removing chips brings the hidden ones back, and the count goes.
  • A value text lists two labels and counts the rest, in the page's language. React and Vue only.
  • A select's value lists two labels and counts the rest.
  • A web select value takes getMoreLabel as a property. Web components only.
Loading more
  • Reaching the last item with the keyboard loads the next page.
  • Scrolling to the end loads the next page, with a status while it does.
  • The last page loads no more.
Rows
  • A recent item is chosen like any other.
  • Typing on a select never lands on it.

Runs in React, Vue and web components.

Match highlighting, here and in Autocomplete and Command:

Combobox
  • Marks the part of each label the text matched.
  • Marks keep the label's own case and accents while matching without them.
  • An item matched by a keyword has nothing to mark.
  • Marks go away when the text is cleared, and the label reads whole.
Autocomplete
  • Marks the part of each suggestion the text matched.
Command
  • Marks each letter a fuzzy match found, joining neighbours.
  • Marks a whole match at a word start.
Highlighting
  • The chosen label in the input shows every item unmarked.

Runs in React, Vue and web components.

Touch screen readers and announcements:

A screen reader's tap moves real focus into the list
  • Autocomplete: tapping the trigger focuses the first suggestion, and Escape returns.
  • Searchable select: tapping the trigger focuses the selected item, not the search field.
Combobox
  • Tapping the trigger focuses the selected item, with no aria-activedescendant.
  • Arrow keys move real focus, and choosing returns focus to the input.
  • Escape closes the list and focus returns to the input.
Announcements
  • How many items match is announced once typing pauses.
  • Autocomplete and searchable select announce counts too.
  • Removing a chip announces which.
Touch screen readers and announcements
  • A tap on the input is for typing: focus stays there.
  • A status part says it instead, so nothing is announced twice.

Runs in React, Vue and web components.

Screen readers hear the same thing in each tested framework, recorded by a virtual screen reader:

  • Announcements while filtering and choosing with a keyboard.

Runs in React, Vue and web components.