--- 
title: Dropdown
description: Select dropdown for single or multi-selection
category: components
alias: select, multi select, combobox, picker
a1Densities: true
group: Forms & Inputs

module: NxDropdownModule
components:
  - name: NxDropdownComponent
    selector: nx-dropdown
    inputs:
      - name: ariaLabelledBy
        default: input<string | null>(null)
        type: "InputSignal<string | null>"
      - name: verticalAlignCheckmark
        default: input<VerticalAlignCheckmark>('top')
        type: "InputSignal<'top' | 'center'>"
      - name: grouped
        desc: "Whether `options` contains groups instead of options. Use `selectGroupLabel` and `selectGroupOptions` to define how to read a group."
        default: input(false, { transform: booleanAttribute })
        type: "InputSignalWithTransform<boolean, unknown>"
      - name: selectValue
        desc: "Selector to get the value of an option. Can be either a property name or a selector function. An empty string uses the whole option as value."
        default: input<string | ((option: S) => any)>('value')
        type: "InputSignal<string | ((option: S) => any)>"
      - name: selectLabel
        desc: "Selector to get the label of an option. Can be either a property name or a selector function. Options without a label display their formatted value."
        default: input<string | ((option: S) => string)>('label')
        type: "InputSignal<string | ((option: S) => string)>"
      - name: selectDisabled
        desc: "Selector to get the disabled state of an option. Can be either a property name or a selector function. An empty string disables no option."
        default: input<string | ((option: S) => boolean)>('disabled')
        type: "InputSignal<string | ((option: S) => boolean)>"
      - name: selectGroupLabel
        desc: "Selector to get the label of a group. Only used when `grouped` is set. Can be either a property name or a selector function."
        default: input<string | ((group: S) => string)>('label')
        type: "InputSignal<string | ((group: S) => string)>"
      - name: selectGroupOptions
        desc: "Selector to get the options of a group. Only used when `grouped` is set. Can be either a property name or a selector function."
        default: input<string | ((group: S) => unknown[])>('options')
        type: "InputSignal<string | ((group: S) => unknown[])>"
      - name: isMultiSelect
        desc: "Whether the dropdown should allow multi selection and additional checkboxes are shown. Note: Please make sure the value you bind is an array.@throws Error if true and the bound value is not an array.    * @deprecated Please use the new `<nx-multi-select>` component instead."
        default: input(false)
        type: "InputSignal<boolean>"
      - name: showFilter
        desc: "Whether the dropdown should be shown with an additional filter input."
        default: input(false)
        type: "InputSignal<boolean>"
      - name: virtualScroll
        desc: "Enable virtual scrolling. Requires using the `options` input (data-driven mode)."
        default: input(this._defaultOptions?.virtualScroll ?? false, {
      transform: booleanAttribute,
    })
        type: "InputSignalWithTransform<boolean, unknown>"
      - name: filterPlaceholder
        desc: "Text displayed as placeholder for the filter."
        default: input('')
        type: "InputSignal<string>"
      - name: overlayLabel
        desc: "Text that is displayed at the top of the overlay. If not set the formfield label is used by default."
        default: input('')
        type: "InputSignal<string>"
      - name: overlayFallbackOrigin
        desc: "Can be used as a fallback to the CdkOverlayOrigin"
        default: input<NxDropdownComponent<any>>()
        type: "InputSignal<NxDropdownComponent<any> | undefined>"
      - name: panelMaxWidth
        default: input<string | number>()
        type: "InputSignal<string | number | undefined>"
      - name: readonly
        desc: "Whether the dropdown is readonly."
        type: "BooleanInput"
      - name: options
        desc: "Array of options for the dropdown, or array of groups when `grouped` is set. Use `selectValue` and `selectLabel` for options that are not an `NxDropdownOption`."
        type: "S[]"
      - name: filterInputType
        desc: "Type of filter input (default: text)."
        type: "'text' | 'number' | 'tel' | 'search' | 'date' | 'datetime' | 'month' | 'email'"
      - name: tabIndex
        type: "number"
      - name: value
        desc: "Selected value"
        type: "any"
      - name: disabled
        desc: "Whether the dropdown is disabled."
        type: "BooleanInput"
      - name: required
        desc: "Whether the component is required. This adds an aria-required label to the component."
        type: "BooleanInput"
      - name: variant
        desc: "If set to 'negative', the component is displayed with the negative set of styles."
        type: "string"
      - name: placeholder
        desc: "Placeholder to be shown if no value has been selected."
        type: "string"
      - name: ignoreItemTruncation
        desc: "Disable truncation of long item texts. We recommend following UX guidelines and always truncating long items. Please only disable truncation if it's impossible to use short descriptions."
        type: "BooleanInput"
      - name: panelMinWidth
        desc: "Sets how the panel min width will be determined. 'trigger' will set the panels min-width to the trigger width. 'none' will not set a min-width and will let the panel grow naturally with its content so it can be smaller than the trigger. This is mostly for special use cases like the country code dropdown in the phone input."
        type: "'trigger' | 'none'"
      - name: panelGrow
        desc: "panelGrow: true means the overlay can grow larger than the trigger and grows with the longest label panelGrow: false means the overlay is the size of the trigger"
        type: "boolean"
      - name: valueFormatter
        desc: "Function that transforms the value into a string. This function is used for displaying and filtering the content.  Default: `(value: any) => value == null ? '' : value.toString()`."
        type: "((value: any) => any) | null | undefined"
      - name: compareWith
        desc: "Function to compare the option values with the selected values. The first argument is a value from an option. The second is a value from the selection. A boolean should be returned.  Defaults to object equality."
        type: "((o1: any, o2: any) => boolean) | null | undefined"
      - name: filterFn
        desc: "Function to be used when the user types into the search filter. The first argument is the user input, the second argument is the dropdown item value as displayed. For items in a group, the third argument is the group label. The dropdown items will use this function to set their visibility state. A boolean should be returned.  Defaults to lower case inclusion, matching either the item label or the group label."
        type: "((query: string, label: string, groupLabel?: string) => boolean) | null | undefined"
    outputs:
      - name: openedChange
        desc: "Event emitted when the select panel has been toggled."
        type: "EventEmitter<boolean>"
      - name: focusOut
        desc: "Event emitted when the select panel has been focus out."
        type: "EventEmitter<boolean>"
      - name: filterResultChange
        desc: "Event emitted when the dropdown items get filtered. Returns the currently visible dropdown items."
        type: "EventEmitter<NxDropdownItemComponent[]>"
      - name: filterChanges
        desc: "Event emitted when the user types in the filter input."
        type: "EventEmitter<any>"
      - name: valueChange
        desc: "Event that emits whenever the raw value of the select changes. This is here primarily to facilitate the two-way binding for the `value` input."
        type: "EventEmitter<any>"
      - name: selectionChange
        desc: "Event emitted when the selected value has been changed."
        type: "EventEmitter<NxDropdownSelectChange<any>>"
    methods:
      - name: setReadonly
        params:
          - name: value
            type: boolean
        desc: "set readonly state"
        returnType: void
      - name: updateErrorState
        params: 
        returnType: void
      - name: focus
        params: 
        desc: "Focuses the select element."
        returnType: void
      - name: onContainerClick
        params:
          - name: event
            type: MouseEvent
        desc: "Takes focus onto the trigger and opens the panel."
        returnType: void
      - name: scrollToIndex
        params:
          - name: index
            type: number
          - name: behavior
            type: ScrollBehavior
        desc: "Scrolls to the option at the specified index. Works for both virtual and non-virtual scroll modes."
        returnType: void
      - name: scrollToValue
        params:
          - name: value
            type: unknown
          - name: behavior
            type: ScrollBehavior
        desc: "Scrolls to the option with the specified value. Uses the compareWith function to match values."
        returnType: void
      - name: openPanel
        params:
          - name: $event
            type: Event
        desc: "Opens the panel of the dropdown."
        returnType: void
      - name: closePanel
        params: 
        desc: "Closes the panel of the dropdown."
        returnType: void
      - name: setDescribedByIds
        params:
          - name: ids
            type: string[]
        desc: "Formfield implementation."
        returnType: void
      - name: setAriaLabel
        params:
          - name: value
            type: string
        desc: "Support for aria-label removed in favor of aria-labelledby The NxFormfieldControl abstract class requires implementation of below method."
        returnType: string
      - name: setDisabledState
        params:
          - name: isDisabled
            type: boolean
        desc: "Disables the select. Part of the ControlValueAccessor interface required to integrate with Angular's core forms API."
        returnType: void
      - name: formatValue
        params:
          - name: value
            type: any
        returnType: string
  - name: NxDropdownItemComponent
    selector: nx-dropdown-item
    inputs:
      - name: idInput
        desc: "Optional ID input. If not provided, an auto-generated ID is used."
        default: input<string | undefined>(undefined, { alias: 'id' })
        type: "InputSignal<string | undefined>"
      - name: value
        desc: "The value of the dropdown item. You can't use undefined, null and '' (empty strings) as they are sentinel values signalling empty data."
        type: "any"
      - name: selectedInput
        desc: "Whether the item is selected (reactive input for virtual scroll)."
        default: input(false, { alias: 'selected', transform: booleanAttribute })
        type: "InputSignalWithTransform<boolean, unknown>"
      - name: activeInput
        desc: "Whether the item is active (reactive input for virtual scroll)."
        default: input(false, { alias: 'active', transform: booleanAttribute })
        type: "InputSignalWithTransform<boolean, unknown>"
      - name: disabled
        desc: "Whether the dropdown item is disabled."
        type: "BooleanInput"
    outputs:
      - name: onSelectionChange
        desc: "Event emitted when the option is selected or deselected."
        type: "EventEmitter<NxDropdownItemChange>"
    methods:
      - name: show
        params: 
        returnType: void
      - name: hide
        params: 
        returnType: void
      - name: select
        params: 
        returnType: void
      - name: deselect
        params: 
        returnType: void
      - name: focus
        params: 
        returnType: void
      - name: setActiveStyles
        params: 
        returnType: void
      - name: setInactiveStyles
        params: 
        returnType: void
      - name: getLabel
        params: 
        desc: "Returns the list item's text label. Implemented as a part of the ListKeyManagerOption."
        returnType: string
  - name: NxDropdownGroupComponent
    selector: nx-dropdown-group
    inputs:
      - name: label
        desc: "Label displayed in the group."
        default: input.required<string>()
        type: "InputSignal<string>"
  - name: NxDropdownClosedLabelDirective
    selector: [nxClosedLabel]
  - name: NxMultiSelectComponent
    selector: nx-multi-select
    desc: |
      Multi Select component.
    inputs:
      - name: grouped
        desc: "Whether `options` contains groups instead of options. Use `selectGroupLabel` and `selectGroupOptions` to define how to read a group."
        default: input(false, { transform: booleanAttribute })
        type: "InputSignalWithTransform<boolean, unknown>"
      - name: selectGroupLabel
        desc: "Selector to get the label of a group. Only used when `grouped` is set. Can be either a property name or a selector function."
        default: input<string | ((group: S) => string)>('label')
        type: "InputSignal<string | ((group: S) => string)>"
      - name: selectGroupOptions
        desc: "Selector to get the options of a group. Only used when `grouped` is set. Can be either a property name or a selector function."
        default: input<string | ((group: S) => unknown[])>('options')
        type: "InputSignal<string | ((group: S) => unknown[])>"
      - name: filterPlaceholder
        desc: "Placeholder for the filter input."
        default: input('Type to filter')
        type: "InputSignal<string>"
      - name: selectValue
        desc: "Selector to get the value of an option. Can be either a property name or a selector function. When providing objects as options, it is recommended to set selectValue to specify a unique identifier for each option. If selectValue is empty, the whole object is used for selection, which may cause issues if object references change."
        default: input<string | ((option: S) => T)>('')
        type: "InputSignal<string | ((option: S) => T)>"
      - name: selectLabel
        desc: "Selector to get the label of an option. Can be either a property name or a selector function. When empty the whole option is treated as the label."
        default: input<string | ((option: S) => string)>('')
        type: "InputSignal<string | ((option: S) => string)>"
      - name: selectDisabled
        desc: "Selector to get the disabled state of an option. Can be either a property name or a selector function."
        default: input<string | ((option: S) => boolean)>()
        type: "InputSignal<string | ((option: S) => boolean) | undefined>"
      - name: panelGrow
        desc: "panelGrow: true means the overlay can grow larger than the trigger and grows with the longest label panelGrow: false means the overlay is the size of the trigger"
        default: input(false, { transform: booleanAttribute })
        type: "InputSignalWithTransform<boolean, unknown>"
      - name: panelMaxWidth
        default: input<string | number>()
        type: "InputSignal<string | number | undefined>"
      - name: virtualScroll
        desc: "Enable virtual scrolling. Only the visible options are rendered, which keeps long lists fast."
        default: input(
      inject(DROPDOWN_DEFAULT_OPTIONS, { optional: true })?.virtualScroll ?? false,
      { transform: booleanAttribute },
    )
        type: "InputSignalWithTransform<boolean, unknown>"
      - name: required
        type: "boolean"
      - name: disabled
        desc: "Whether the multi select is disabled."
        type: "boolean"
      - name: readonly
        desc: "Whether the multi select should be read only."
        type: "BooleanInput"
      - name: placeholder
        desc: "The placeholder shown in the multi select field."
        type: "string"
      - name: filter
        desc: "Whether this multi select can be filtered."
        type: "BooleanInput"
      - name: disableSelectAll
        desc: "Whether the (select all / clear all) should be disabled and hidden."
        type: "BooleanInput"
      - name: filterFn
        desc: "Function to be used when the user types into the search filter. The first argument is the user input, the second argument is the dropdown item value as displayed. When `grouped` is set, the third argument is the label of the option's group. The dropdown items will use this function to set their visibility state. A boolean should be returned.  Defaults to lower case inclusion, matching either the option label or the group label."
        type: "((query: string, label: string, groupLabel?: string) => boolean) | null | undefined"
      - name: tabIndex
        type: "number"
      - name: options
        desc: "List of options to choose from, or list of groups when `grouped` is set."
        type: "S[]"
    outputs:
      - name: openedChange
        desc: "Event emitted when the select panel has been toggled."
        type: "EventEmitter<boolean>"
      - name: selectionChange
        desc: "Event emitted when the selected value has been changed."
        type: "EventEmitter<T[]>"
      - name: focusOut
        desc: "Event emitted when the select panel has been focus out."
        type: "EventEmitter<boolean>"
      - name: filterChanges
        desc: "Event emitted when the user types in the filter input."
        type: "EventEmitter<any>"
    methods:
      - name: setDisabledState
        params:
          - name: isDisabled
            type: boolean
        returnType: void
      - name: setDescribedByIds
        params:
          - name: ids
            type: string[]
        returnType: void
      - name: onContainerClick
        params:
          - name: event
            type: MouseEvent
        desc: "Takes focus onto the trigger and opens the panel."
        returnType: void
      - name: open
        params:
          - name: $event
            type: Event
          - name: origin
            type: FocusOrigin
        returnType: void
      - name: updateErrorState
        params: 
        returnType: void
      - name: scrollToIndex
        params:
          - name: index
            type: number
          - name: behavior
            type: ScrollBehavior
        desc: "Scrolls to the option at the given index, counted in the order the options are currently displayed. Only has an effect after the panel has opened. With virtual scrolling, the option is rendered asynchronously."
        returnType: void
      - name: scrollToValue
        params:
          - name: value
            type: T
          - name: behavior
            type: ScrollBehavior
        desc: "Scrolls to the option with the given value."
        returnType: void
  - name: NxMultiSelectOptionComponent
    selector: nx-multi-select-option
    desc: |
      A single option witin the multi select.
    inputs:
      - name: appearance
        default: input<AppearanceType>('auto')
        type: "InputSignal<AppearanceType>"
      - name: value
        desc: "Value of this option."
        default: input<T>()
        type: "InputSignal<T | undefined>"
      - name: label
        desc: "Label of this option."
        default: input('')
        type: "InputSignal<string>"
      - name: selected
        desc: "Whether this option is selected."
        default: false
        type: "boolean"
      - name: disabled
        desc: "Whether this option is disabled."
        default: false
        type: "boolean"
      - name: active
        desc: "Sets this option active highlighting it to the user."
        type: "boolean"
    outputs:
      - name: selectedChange
        desc: "Emits an event when this option is selected or unselected by the user."
        type: "EventEmitter<boolean>"
    methods:
      - name: setActiveStyles
        params: 
        returnType: void
      - name: setInactiveStyles
        params: 
        returnType: void
      - name: selectViaInteraction
        params: 
        desc: "Selects this option as if the user clicked on it."
        returnType: void
      - name: getLabel
        params: 
        returnType: string
  - name: NxMultiSelectAllComponent
    selector: nx-multi-select-all
    desc: |
      A single option witin the multi select.
    inputs:
      - name: value
        desc: "Value of this option."
        default: input<T>()
        type: "InputSignal<T | undefined>"
      - name: label
        desc: "Label of this option."
        default: input('')
        type: "InputSignal<string>"
      - name: selected
        desc: "Whether this option is selected."
        default: false
        type: "boolean"
      - name: disabled
        desc: "Whether thisoption is disabled."
        default: false
        type: "boolean"
      - name: indeterminate
        desc: "Indeterminate"
        type: "boolean"
    outputs:
      - name: selectedAllChange
        desc: "Emits an event when this option is selected or unselected by the user."
        type: "EventEmitter<boolean>"
    methods:
      - name: setActiveStyles
        params: 
        returnType: void
      - name: setInactiveStyles
        params: 
        returnType: void
      - name: selectViaInteraction
        params: 
        desc: "Selects this option as if the user clicked on it."
        returnType: void
      - name: getLabel
        params: 
        returnType: string

---
# Overview
It is recommended to use the dropdown component in combination with NxFormField. Therefore, make sure to import this module as well:

```ts
import { NxFormfieldModule } from '@allianz/ng-aquila/formfield';
```

Dropdown requires Angular CDK (incl. CSS). Learn [how to enable Angular CDK styles](./documentation/overlay/overview#angular-cdk).
