Combobox

May 12, 2026 ยท View on GitHub

npm license

Angular Select - Lightweight all in one UI Select, Multiselect and Autocomplete

Documentation | Examples

Compatibility

Angular@ng-matero/ng-select
>=17.31.x

Installation

npm install @ng-matero/ng-select --save

Inlcude styles

@use '@ng-matero/ng-select';
CSS Variables
--ns-multi-value-text-color
--ns-multi-value-background-color
--ns-multi-value-remove-hover-text-color
--ns-multi-value-remove-hover-background-color
--ns-multi-value-remove-icon-size
--ns-multi-value-remove-padding
--ns-multi-value-gap
--ns-multi-value-shape
--ns-multi-value-vertical-padding
--ns-multi-value-horizontal-padding
--ns-multi-value-text-size
--ns-multi-value-line-height
--ns-multi-value-label-padding

--ns-control-background-color
--ns-control-outline-color
--ns-control-hover-outline-color
--ns-control-focus-outline-color
--ns-control-focus-shadow
--ns-control-disabled-outline-color
--ns-control-disabled-background-color
--ns-control-shape
--ns-control-min-height
--ns-placeholder-text-color
--ns-value-container-vertical-padding
--ns-value-container-horizontal-padding

--ns-indicator-color
--ns-indicator-hover-color
--ns-indicator-focus-color
--ns-indicator-focus-hover-color
--ns-indicator-padding

--ns-panel-background-color
--ns-panel-shadow
--ns-panel-shape
--ns-panel-vertical-padding
--ns-panel-vertical-margin
--ns-panel-max-height

--ns-option-hover-background-color
--ns-option-selected-text-color
--ns-option-selected-background-color
--ns-option-disabled-text-color
--ns-option-child-indent
--ns-optgroup-padding
--ns-optgroup-text-color
--ns-optgroup-text-size
--ns-option-padding
--ns-tag-option-gap

Usage

import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-matero/ng-select';

@Component({
  selector: 'your-app',
  template: `
    <!-- Using items input -->
    <ng-select [items]="cars" bindLabel="name" bindValue="id" [(ngModel)]="selectedCar" />

    <!-- Using ng-option and for loop -->
    <ng-select [(ngModel)]="selectedCar">
      @for (car of cars; track car.id) {
        <ng-option [value]="car.id">{{ car.name }}</ng-option>
      }
    </ng-select>
  `,
  imports: [FormsModule, NgSelectModule],
})
export class YourAppComponent {
  cars = [
    { id: 1, name: 'Volvo' },
    { id: 2, name: 'Saab', disabled: true },
    { id: 3, name: 'Opel' },
    { id: 4, name: 'Audi' },
  ];
  selectedCar = 3;
}

Templates

Use template directives to customize the rendering of specific components:

<ng-select [items]="cars" bindLabel="name" bindValue="id" [(ngModel)]="selectedCar">
  <ng-template ngSelectLabel let-item="item">
    <img height="15" width="15" [src]="item.cover" alt="" />
    {{ item.name }}
  </ng-template>
</ng-select>

View more template examples

API

Inputs

NameTypeDefaultDescription
[addTag]boolean | AddTagFnfalseAllows to create custom options.
[addTagText]string'Add item'Set custom text when using tagging.
[appendTo]stringnullAppend dropdown to body or any other element using css selector. For correct positioning body should have position:relative.
[bindValue]stringObject property to use for selected model. By default binds to whole object.
[bindLabel]string'label'Object property to use for label.
[closeOnSelect]booleantrueWhether to close the menu when a value is selected.
[clearAllText]string'Clear all'Set custom text for clear all icon title.
[clearable]booleantrueAllow to clear selected value.
[clearOnBackspace]booleantrueClear selected values one by one when clicking backspace.
[compareWith]CompareWithFnA function to compare the option values with the selected values.
[items]any[][]Items array.
[panelPosition]PanelPosition'auto'Set the panel position on open.
[panelDisabled]booleanfalseWhether disable the panel opening.
[panelClass]string | string[] | Record<string, any>This method takes classes set on the ng-select panel element.
[groupBy]string | ((value: any) => any)Allow to group items by key or function expression.
[groupValue]GroupValueFnFunction expression to provide group value.
[selectableGroup]booleanfalseAllow to select group when groupBy is used.
[selectableGroupAsModel]booleantrueIndicates whether to select all children or group itself.
[loading]booleanYou can set the loading state from the outside (e.g. async items loading).
[loadingText]string'Loading...'Set custom text when for loading items.
[markFirst]booleantrueMarks first item as focused when opening/filtering.
[maxSelectedItems]numberWhen multiple is true, allows to set a limit number of selection.
[hideSelected]booleanfalseAllows to hide selected items.
[multiple]booleanfalseAllows to select multiple items.
[notFoundText]string'No items found'Set custom text when filter returns empty result.
[placeholder]stringPlaceholder text.
[searchable]booleantrueAllow to search for value.
[readonly]booleanfalseSet ng-select as readonly. Mostly used with reactive forms.
[searchFn]SearchFnnullAllow to clear selected value.
[searchWhileComposing]booleantrueWhether items should be filtered while composition started.
[trackByFn]TrackByFnnullProvide custom trackBy function.
[clearSearchOnAdd]booleantrueClears search input when item is selected. Default false when closeOnSelect is false.
[editableSearchTerm]booleanfalseAllow to edit search query if option selected. Works only if multiple is false.
[selectOnTab]booleantrueSelect marked dropdown item using tab.
[openOnEnter]booleantrueOpen dropdown using enter.
[typeahead]SubjectCustom autocomplete or advanced filter.
[minTermLength]number0Minimum term length to start a search. Should be used with typeahead.
[typeToSearchText]string'Type to search'Set custom text when using Typeahead.
[virtualScroll]booleanfalseEnable virtual scroll for better performance when rendering a lot of data.
[bufferAmount]number4Used in virtual scrolling, the bufferAmount property controls the number of items preloaded in the background to ensure smoother and more seamless scrolling.
[keyDownFn](e: KeyboardEvent) => booleantrueProvide custom keyDown function. Executed before default handler. Return false to suppress execution of default key down handlers.
[fixedPlaceholder]booleanfalseSet placeholder visible even when an item is selected.
[deselectOnClick]booleanfalseDeselects a selected item when it is clicked in the dropdown. Default true when multiple is true.
[preventToggleOnRightClick]booleanfalsePrevent opening of ng-select on right mouse click.
[tabIndex]numberThe tabindex of ng-select input.
[inputId]stringThe input id.
[inputAttrs]{ [key: string]: string }Pass custom attributes to underlying input element.
[ariaLabel]stringaria-label of the ng-select input.
[ariaLabelledby]stringaria-labelledby of the ng-select input.
[ariaDescribedby]stringaria-describedby of the ng-select input.

Outputs

NameTypeDescription
(focus)FocusEventFired on select focus.
(blur)FocusEventFired on select blur.
(change)anyFired on model change. Outputs whole model.
(open)voidFired on select dropdown open.
(close)voidFired on select dropdown close.
(add)anyFired when item is added while multiple is true. Outputs added item.
(remove)anyFired when item is removed while multiple is true.
(search)SearchEventFired while typing search term. Outputs search term with filtered items.
(clear)voidFired on clear icon click.
(scroll)ScrollEventFired when scrolled. Provides the start and end index of the currently available items. Can be used for loading more items in chunks before the user has scrolled all the way to the bottom of the list.
(scrollToEnd)voidFired when scrolled to the end of items. Can be used for loading more items in chunks.

Methods

NameDescription
openOpens the select dropdown panel.
closeCloses the select dropdown panel.
focusFocuses the select element.
blurBlurs the select element.

License

MIT