Select

Vue Bootstrap 5 Select

Vue Select fields components are used for collecting user provided information from a list of options.

Note: Read the API tab to find all available options and advanced customization


Basic example

Select options are added using v-model with the options argument. You can get selected values in two ways. The first is to filter the data given in v-model:options by a selected key. The second method is to use v-model:selected which is read-only and stores the currently selected options as a string (single select) or as an array (multiple select).

Basic select behaves like a native one and by default marks the first available option as selected. To change this setting, easily set the preselect property to false.


Multiselect

Add multiple property to the select component to activate multiple mode.


Select with label

It is possible to add select label by setting the label property.


Select with placeholder

Use placeholder property to set placeholder for select input. The placeholder will be displayed when input is focused and no option is selected.


Disabled select

Add disabled attribute to the select component to disable select input.


Disabled options

Use disabled key on option element to disable specific option.


Clear button

Set clearButton property to display the button that will allow to clear current selections.


Custom content

Custom content will be displayed at the end of the select dropdown.


Visible options

Use visibleOptions property to change the number of options that will be displayed in the select dropdown without scrolling.


Secondary text

Add secondary-text key to the specific options to display secondary text.



Select with search inside a modal


Option groups

It is possible to group options by using optgroup key.


Select with icons

Add icon property to the specific options to display the option icon.


Validation

Set isValidated and isValid properties to enable component validation. The validFeedback and invalidFeedback options allow to modify the validation messages. Validate method can be set on select's change event.


Set value

The setValue method allows to programatically set the component selections.


Single selection

Add single value string to the arguments list to correctly select option with corresponding value in single selection mode.


Multi selection

Add array of string values to the arguments list to correctly select options with corresponding values in multi selection mode.

Select - API


Import


        import { MDBSelect } from "mdb-vue-ui-kit";
      

Properties

Property Type Default Description
clearButton Boolean false Adds clear button to the select input.
disabled Boolean false Changes select input state to disabled.
displayedLabels Number 5 The maximum number of comma-separated list of options displayed on the Multiselect. If a user selects more options than that value, the X options selected text will be displayed instead. If set to -1, the limit is off.
filter Boolean false Displays filter input that allow to search for specific option.
filterDebounce Number 300 Adds delay to the options list updates when using filter input. Improves performance of the select with filter.
invalidFeedback String The text which is displayed below the select when the isValidated property is true and isValid prop is false.
isValidated Boolean false Marks select as validated.
isValid Boolean false Marks select as valid.
label String Defines select input label.
multiple Boolean false Enables multiple mode.
noResultsText String "No results" The text that will be displayed when no option is found after using select filter.
optionHeight Number 38 Height of the select option. Used to determine dropdown height and number of visible options.
optionsSelectedLabel String "options selected" The text which is displayed on the Multiselect when there are more than 5 (default) options selected, e.g. 7 options selected
placeholder String Defines select input placeholder.
preselect Boolean true Basic select behaves like a native one and by default marks the first available option as selected. To change this setting, easily set this property to false.
required Boolean false Changes select input state to required.
searchPlaceholder String "Search..." Changes placeholder of the select search input.
selectAll Boolean true Displays select all option in multiselect dropdown.
selectAllLabel String "Select all" Changes label of select all option.
size String Changes input size. Available options: sm, lg, default.
tag String "div" Defines select wrapper tag.
validFeedback String The text which is displayed below the select when the isValidated and isValid properties are true.
visibleOptions Number 5 The maximum number of options which are visible in the select dropdown without scrolling.
v-model:options Array Data array required to fill select component.
v-model:selected [String, Array, Number] Readonly and reactive property for getting selected values.

Methods

Name Description Example
clear Manually clears a selection $refs.select1.clear();
close Manually closes a select $refs.select1.close();
open Manually opens a select $refs.select1.open();
setValue Programatically set component selections. Add single value for default select and array of values for multiselect. $refs.select1.setValue(3);
setOption Programatically set component selections by an option key. Use -1 key to select all in multiple mode. $refs.select1.setOption(2);
toggle Manually toggles a select $refs.select1.toggle();
toggleSelectAll Toggle select all. $refs.select1.toggleSelectAll();

        <MDBSelect v-model:options="options1" ref="select1" />
        <MDBBtn @click.stop="$refs.select1.setValue(3)" color="primary">Select three</MDBBtn>
      

Events

Name Description
change This event fires immediately on every select data change.
clear This event fires immediately when the select is cleared.
close This event fires immediately when the select is closed.
open This event fires immediately when the select is opened.

        <MDBSelect v-model:options="options1" @clear="handleClear" />