--- title: Configuration taxonomy: category: docs --- Select2 has the following configuration options available. Note that this page is a work in progress. The previous release's documentation should cover the gaps here for the time being.
Option Type Description
adaptContainerCssClass
adaptDropdownCssClass
ajax
allowClear boolean

When set to true, causes a clear button to appear on the select box when a value is selected. Clicking the clear button will clear the selected value, effectively resetting the select box back to its placeholder value.

Default value: false

amdBase string

The base AMD loader path to be used for select2 dependency resolution. This option typically doesn't need to be changed, but is available for situations where module names may change as a result of certain build environments.

Default value: `select2/`

amdLanguageBase string

The base AMD loader language path to be used for select2 language file resolution. This option typically doesn't need to be changed, but is available for situations where module names may change as a result of certain build environments.

Default value: `select2/i18n/`

closeOnSelect boolean

When set to false, keeps the dropdown open upon selecting an option, making it easy to quickly select multiple items. Note that this option is only applicable to multi-select controls.

Default value: `true`

containerCss
containerCssClass
dataAdapter
debug boolean
dir
disabled boolean

When set to true, the select control will be disabled.

Default value: false

escapeMarkup
initSelection
language string or object
matcher A callback taking search params and the data object.
maximumInputLength integer

Maximum number of characters that may be provided for a search term.

Default value: 0

maximumSelectionLength integer

The maximum number of items that may be selected in a multi-select control. If the value of this option is less than 1, the number of selected items will not be limited.

Default value: 0

minimumInputLength integer

Minimum number of characters required to start a search. This options is primarily useful in cases where data is loaded via the ajax option.

Default value: 0

minimumResultsForSearch integer

The minimum number of results required in the initial population of the dropdown to keep the search box. This option is useful for cases where local data is used with a small result set, and the search box would simply be a waste of screen real estate. Set this value to -1 to permanently hide the search box.

Default value: 0

multiple boolean This option enables multi-select (pillbox) mode. Select2 will automatically map the value of the `multiple` HTML attribute to this option during initialization.
placeholder string or object
query
resultsAdapter
selectionAdapter
selectOnClose boolean

Default value: false

sorter function
tags boolean / array of objects
templateResult callback
templateSelection callback
theme string

Default value: default

tokenizer
tokenSeparators
width string

Specifies the width style attribute of the select2 container. The following values are supported:

element
Uses the computed element width from any applicable CSS rules.
resolve
Uses the style attribute value if available, falling back to the computed element width as necessary.
style
Width is determined from the select element's style attribute. If no style attribute is found, null is returned as the width.
{width_value}
Valid CSS values can be passed as a string (i.e. 80%).

Default value: resolve