Checkbox
BsCheckbox is a component that let users select one or more items from a list, or turn an item on or off.
Overview
BsCheckbox component mimics the HTML5 <input type="checkbox"> element. This means that you can add attributes like required, readonly, or disabled 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.
Checkbox Group
BsCheckboxGroup is a collection of BsCheckbox. Rather than create multiple <bs-checkbox>, it's better to create single <bs-checkbox-group>. <bs-checkbox-group> can be integrated with external validator plugin such as Vuelidate.
INFO
<bs-checkbox-group> will be displayed in one column if the media query matches (max-width: 575px). And if the media query matches (min-width: 576px) it will try to fit up to four columns.
Multi Column
With <bs-checkbox-group>, collection of <bs-checkbox> can be arranged in multi-columns. When the number of <bs-checkbox> exceed the number of maximum columns, then the remaining <bs-checkbox> will be placed on the next row.
INFO
Multi columns are closely tied to the bootstrap class col-lg-*. Which means if the media query matches (min-width: 992px), it will be displayed correctly. And if the media query matches (min-width: 768px), it will be displayed in two columns only.
Colors
Use color property to change <bs-checkbox> or <bs-checkbox-group> color appearance. Additionally, you can set each checkbox of <bs-checkbox-group> to have different color.
Custom Checkbox
The following is an example that demonstrate how to customize checkbox appearance via css variables.
Added in v2.0.7CSS Variables
As CSS technology evolves, Vue MDBootstrap introduces local CSS variables on .md-checkbox for better customization.
.md-checkbox {
--md-checkbox-size: #{vars.$checkbox-size};
--md-checkbox-touch-size: #{vars.$checkbox-touch-size};
--md-checkbox-border-radius: #{vars.$radius};
--md-checkbox-stroke: #{vars.$checkbox-stroke};
--md-checkbox-margin: #{vars.$checkbox-margin};
--md-checkbox-indeterminate-width: #{vars.$checkbox-indeterminate-width};
--md-checkbox-disabled-opacity: var(--md-field-disabled-opacity);
--md-checkbox-checkmark-height: #{vars.$checkbox-checkmark-height};
--md-checkbox-checkmark-width: #{vars.$checkbox-checkmark-width};
--md-checkbox-checkmark-pos-x: 4px;
--md-checkbox-checkmark-pos-y: 0;
--md-checkbox-disabled-bg: transparent;
--md-checkbox-unchecked-bg: transparent;
--md-checkbox-unchecked-color: currentColor;
--md-checkbox-checked-bg: #{$color};
--md-checkbox-checked-color: #{$checked-color};
}API Reference
BsCheckbox
BsCheckboxGroup
TCheckboxInputProps
| Property | Type | Description |
|---|---|---|
| value required | String|Number | The <bs-checkbox> value. |
| label required | String | The <bs-checkbox> label. |
| color | String | The <bs-checkbox> color appearance. Updated in v2.2.0 Built-in color variants are: default, primary, secondary, success, warning, danger and info. |
| disabled | Boolean | Create <bs-checkbox> in disabled state. |
| readonly | Boolean | Create <bs-checkbox> in readonly state. |
| id | String | Sets the <bs-checkbox> element ID attribute. This property value is auto generates. |
| name | Boolean | Sets the <bs-checkbox> element name attribute. |
| indeterminate | Boolean | Sets an indeterminate state for the <bs-checkbox>. |
