Select2 can take a regular select box with search options within the Select control.
Use .select2
class for basic select2 control.
Select2's width can be set to a percentage of its parent to support responsive design. The two Select2 boxes below are styled to 50%.
A placeholder value can be defined and will be displayed until a selection is made. Select2 uses the placeholder attribute on multiple select boxes.
Select2 will respond to the disabled
attribute on <select>
elements. You can also initialize Select2 with disabled: true
to get the same effect.
Select2 allows you to hide the search box depending on the number of options which are displayed. In this example, we use the value Infinity
to tell Select2 to never display the search box.
Use data attribute data-icon
to add icon name for each options. And use class .select2-icons
to set icon with option.
Select2 also supports multi-value select boxes. The select below is declared with the multiple
attribute.
Use .select2
class for basic select2 control. Use multiple="multiple"
attribute for multiple select box.
Select2's width can be set to a percentage of its parent to support responsive design. The two Select2 boxes below are styled to 75%.
Select2 will respond to the disabled
attribute on <select>
elements. You can also initialize Select2 with disabled: true
to get the same effect.
Select2 multi-value select boxes can set restrictions regarding the maximum number of options selected. The select below is declared with the multiple
attribute with maximumSelectionLength
in the select2 options.
Use data attribute data-icon
to add icon name for each options. And use class .select2-icons
to set icon with option.