Search documentation

Search the documentation and open a page.

An input that allows users to filter and select a value from a list of suggestions.

Loading...

Installation

pnpm dlx shadcn@latest add @wirekyt/combobox

Composition

<app-combobox> ├── [app-combobox-label] (optional) ├── <app-combobox-input> | <app-combobox-trigger> ├── [app-combobox-tags-control] (multiple selection) │ ├── <app-combobox-tag> │ └── <input app-combobox-tags-input> └── <app-combobox-content> ├── <app-combobox-input> (optional, with a button trigger) ├── [app-combobox-empty] (optional) └── [app-combobox-list] ├── [app-combobox-item-group] │ ├── [app-combobox-item-group-label] │ └── <app-combobox-item> └── [app-combobox-separator] (optional)

Examples

Button Trigger

Loading...

Default

Loading...

Groups

Loading...

Multiple Selection

Loading...

Single Selection

Loading...

Sizes

Loading...

With Description

Loading...

API Reference

<app-combobox>

Inputs

InputTypeDefaultDescription
collectionListCollection<T>requiredCollection that supplies the items, values, and display strings.
idstring | undefinedgeneratedUnique identifier used to create the combobox part IDs.
idsComboboxElementIds | undefined—Overrides the generated IDs for individual parts.
valuestring[] | undefined—Selected values when controlled. Supports Angular two-way binding.
defaultValuestring[] | undefined[]Initially selected values when uncontrolled.
inputValuestring | undefined—Input text when controlled. Supports Angular two-way binding.
defaultInputValuestring | undefined""Initial input text when uncontrolled.
openboolean | undefined—Open state when controlled. Supports Angular two-way binding.
defaultOpenbooleanfalseInitial open state when uncontrolled.
highlightedValuestring | null | undefined—Highlighted item value when controlled. Supports Angular two-way binding.
defaultHighlightedValuestring | null | undefined—Initially highlighted item value when uncontrolled.
multiplebooleanfalseAllows more than one value to be selected.
disabledbooleanfalseDisables interaction with the combobox.
invalidbooleanfalseMarks the associated form control as invalid.
readOnlybooleanfalsePrevents changes while preserving focus and navigation.
requiredbooleanfalseMarks the associated form control as required.
allowCustomValuebooleanfalseAllows values that are not present in the collection.
autoFocusbooleanfalseFocuses the input when the component initializes.
openOnClickbooleanfalseOpens the suggestions when the input is clicked.
openOnKeyPressboolean | undefinedtrueControls whether typing or navigation keys open the suggestions.
alwaysSubmitOnEnterbooleanfalseAllows Enter to submit the containing form when no item is selected.
closeOnSelectboolean | undefined!multipleControls whether the suggestions close after a selection.
loopFocusboolean | undefinedtrueControls whether keyboard focus wraps through the items.
compositeboolean | undefinedtrueEnables composite-widget keyboard navigation.
disableLayerboolean | undefined—Disables the dismissable layer used by the floating content.
inputBehavior"autohighlight" | "autocomplete" | "none" | undefined"none"Controls how input text affects the highlighted suggestion.
selectionBehavior"clear" | "replace" | "preserve" | undefinedmultiple ? "clear" : "replace"Controls how the input text changes after selection.
openOnChangeboolean | ((details: ComboboxInputValueChangeDetails) => boolean) | undefinedtrueControls whether an input-value change opens the suggestions.
placeholderstring | undefined—Placeholder used by the combobox state machine.
namestring | undefined—Name used when submitting the selected values with a form.
formstring | undefined—Associates the control with a form by ID.
positioningComboboxPositioningOptions | undefined—Configures floating-content placement and collision handling.
scrollToIndexFn((details: ComboboxScrollToIndexDetails) => void) | undefined—Customizes scrolling when the highlighted item changes.
navigate((details: ComboboxNavigateDetails) => void) | null | undefined—Handles navigation for items that represent links.
translationsComboboxIntlTranslations | undefined—Overrides accessible labels used by the component.

Outputs

OutputTypeDescription
valueChangestring[] | undefinedEmits the current selected values.
inputValueChangestring | undefinedEmits the current input text.
openChangeboolean | undefinedEmits the current open state.
highlightedValueChangestring | null | undefinedEmits the current highlighted item value.
valueChangeDetailsComboboxValueChangeDetails<T>Emits details whenever the selected values change.
inputValueChangeDetailsComboboxInputValueChangeDetailsEmits details whenever the input text changes.
highlightChangeComboboxHighlightChangeDetails<T>Emits details whenever the highlighted item changes.
openChangeDetailsComboboxOpenChangeDetailsEmits details whenever the open state changes.
selectComboboxSelectionDetailsEmits when an item is selected.
focusOutsideComboboxFocusOutsideEventEmits when focus moves outside the floating layer.
pointerDownOutsideComboboxPointerDownOutsideEventEmits when a pointer is pressed outside the floating layer.
interactOutsideComboboxInteractOutsideEventEmits when an interaction occurs outside the floating layer.

<app-combobox-input>

Inputs

InputTypeDefaultDescription
idstring | undefined—ID applied to the generated input element.
placeholderstring""Placeholder displayed by the input.
disabledbooleanfalseDisables the input and its generated controls.
showTriggerbooleantrueShows the generated dropdown trigger.
showClearbooleanfalseShows the generated clear trigger.
size"default" | "lg" | "xl""default"Sets the input-group size.

<app-combobox-item>

Inputs

InputTypeDefaultDescription
itemTrequiredCollection item represented by this option.
persistFocusboolean | undefined—Preserves visual focus while interacting with the option.

[app-combobox-item-group]

Inputs

InputTypeDefaultDescription
idstring | undefinedgeneratedIdentifier shared with the group label.

<app-combobox-tag>

Inputs

InputTypeDefaultDescription
valuestringrequiredSelected value represented by the tag.
removablebooleanfalseShows a button for dismissing the selected value.

Outputs

OutputTypeDescription
removestringEmits the tag value when its remove button is activated.

Context, Providers, and Utilities

ExportAngular API
ComboboxRootProviderDirective that provides an externally created combobox API through value.
ComboboxContextStructural directive [combobox-context] exposing the root API to a template.
ComboboxItemContextDirectiveStructural directive [combobox-item-context] exposing the current item state.
useCombobox(options)Creates the signal-backed combobox machine inside an Angular injection context.
injectComboboxContext()Injects the nearest root combobox context.
injectComboboxItemContext()Injects the nearest item context.
injectComboboxItemGroupContext()Injects the nearest item-group context.
createListCollection(options)Creates the typed collection consumed by the combobox.
useListCollection(options)Creates and manages a signal-backed list collection.
ComboboxImportsReadonly collection containing the combobox UI and context helpers.

Types

ExportDescription
ComboboxApiConnected combobox state and actions.
ComboboxElementIdsOverrides for generated combobox part IDs.
ComboboxValueChangeDetails<T>Details emitted by valueChangeDetails.
ComboboxInputValueChangeDetailsDetails emitted by inputValueChangeDetails.
ComboboxHighlightChangeDetails<T>Details emitted by highlightChange.
ComboboxOpenChangeDetailsDetails emitted by openChangeDetails.
ComboboxSelectionDetailsDetails emitted by select.
UseComboboxReturn<T>Signal-backed combobox machine returned by useCombobox.