Skip to content

Combobox

BsCombobox is a form field component that let users select one or more items from a dropdown displayed list.

Overview

BsCombobox uses BsListbox and BsPopover components internally and mimics like HTML combobox: <select> element. This means that you can add attributes like readonly, disabled, required and it will react to them to give the best experience. You can also use v-model directive to create two-way data bindings on the model-value property.

IMPORTANT

Do not use the model-value property when using v-model.

Style Variants

You can style <bs-combobox> to your own preference or use a style variant based on Google Material Design 2 or Material Design 3 specifications.

Default

You can style <bs-combobox> that follows Google Material Design 2 specifications by using floating-label property explicitly.

Filled

Use filled property explicitly to enable <bs-combobox> with solid fill style. And when combined with floating-label property, <bs-combobox> will have a style that follows the Google Material Design 3 specifications.

Outlined

Use outlined property explicitly to enable <bs-combobox> with outline style. And when combined with floating-label property, <bs-combobox> will have a style that follows the Google Material Design 3 specifications.

Clearable

Define the clear-button property explicitly, so that the field value can be cleared easily.

Multiple Selection

<bs-combobox> support multiple selection. Multiple selection feature can be enabled using the multiple property explicitly.

Checkbox Position and Color

In multiple selection mode, the checkbox color can be changed via checkbox-color property and the position can be changed via checkbox-position property. Valid values for this property are: left (default), right. If these property is not defined, then default value will be used.

TIP

Any MDBootstrap Color variants and Material Color variants can be applied to the checkbox-color property.

Chips Mode

In multiple selection mode, the selected items can be display as chips. Use property chip-enabled explicitly to display the selected items as chips. Additionally you can use chip-color property to set the chips color and chip-outlined or chip-pill to style the chips appearance.

Updated on v2.0.0

TIP

Any MDBootstrap Color variants and Material Color variants can be applied to the chip-color property.

Cascade Support

<bs-combobox> component supports cascade selection or parent-child relationship
when there are two or more <bs-combobox> components.

To activate this feature, sets the parent-value property on child component to the parent component model-value and use the cascadeField property on the configuration schema to point to the field that has relation to the parent. By default, the value of cascadeField property is set to parent.

Image Support

<bs-combobox> component supports displaying images or avatars. This feature can be enabled using the show-image property explicitly and use imageField property on the configuration schema to point to the image field in the datasource. By default, the value of property imageField is set to image.

Image Size And Shape

The size of images can be controlled via image-size property. Sets this property to the desired numbers of pixels and the image will displayed according to this value. And use rounded-image or circle-image property to change its shape.

Hover Display Support

The Listbox popup can be displayed using hover instead of clicking with the open-on-hover property.

Help Text

The help-text property on <bs-combobox> adds an help text beneath the combobox. And sets the persistent-help-text property to false will make the help text visible only when the combobox is focused.

Icons

The properties prepend-icon, prepend-icon-outer, append-icon and append-icon-outer provides the ability to add icon to <bs-combobox>.

Use any valid android icon name from Google Material Symbols with or without a suffix. Valid suffixes are: _outlined, _rounded, _sharp, _filled, _outlined_filled, _rounded_filled, and _sharp_filled. Suffix _filled and _outlined_filled will display the same icon style variant.

Updated on v2.1.0

INFO

Since Vue MDBootstrap v2.1.0, Google Material Icons are replaced with Google Material Symbols.

Usage Example

The following is an example that demonstrate more advanced use of the <bs-combobox> with form validation.

CSS Variables

Added since v2.0.0
scss
--md-field-active-border-color: rgb(var(--md-field-active-indicator));
--md-field-active-border-width: 2px;
--md-field-color-bg: currentColor;
--md-field-border-color: currentColor;
--md-field-border-width: 1px;
--md-field-floating-label-color: var(--md-field-label-color);
--md-field-label-color: currentColor;

// global css variables
--md-field-primary-indicator-rgb: 98, 0, 238;
--md-field-primary-indicator: rgb(var(--md-field-primary-indicator-rgb));
--md-field-accent-indicator-rgb: 185,156,225;
--md-field-accent-indicator: rgb(var(--md-field-accent-indicator-rgb));
--md-field-active-indicator: var(--md-field-primary-indicator-rgb);

API Reference

TValidator

The validator configuration option has properties as described below:

PropertyTypeDescription
validatorsRecord<String,Boolean>External validator plugin validation result.
messagesRecord<String,String>Validation message for each validation types.
hasErrorBooleanAn indicator that tells the field value pass the validation or not.
dirtyBooleanValue comes from validator plugin that indicate the field is dirty or not.

All properties are mandatory.

NOTE

Vue MDBootstrap does not include form validation by default, we leave that up to the 3rd party form validation plugin. As of now, Vuelidate has been fully tested with our component library.

Released under the BSD-3-Clause License.