Skip to content

Radio Button

BsRadio is a component that let users select one option from a set of options.

Overview

BsRadio component mimics the HTML5 <input type="radio"> 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.

Select an option
Value:

Radio Group

BsRadioGroup is a collection of BsRadio. Rather than create multiple <bs-radio>, it's better to create single <bs-radio-group>. <bs-radio-group> can be integrated with external validator plugin such as Vuelidate.

Selected color:

Selected fruit:

INFO

<bs-radio-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-radio-group>, collection of <bs-radio> can be arranged in multi-columns. When the number of <bs-radio> exceed the number of maximum columns, then the remaining <bs-radio> will be placed on the next row.

Selected item:

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-radio> or <bs-radio-group> color appearance. Additionally, you can set each radio of <bs-radio-group> to have different color.

Updated in v2.2.0

CSS Variables

As CSS technology evolves, Vue MDBootstrap introduces local CSS variables on .md-radio for better customization.

Updated in v2.2.0
scss
.md-radio {
  --md-radio-size: #{vars.$radio-size};
  --md-radio-touch-size: #{vars.$radio-touch-size};
  --md-radio-stroke: #{vars.$radio-stroke};
  --md-radio-margin: #{vars.$radio-margin};

  --md-radio-color: currentColor;
  --md-radio-active-color: #{$color};
  --md-radio-disabled-bg: transparent;
  --md-radio-disabled-opacity: var(--md-field-disabled-opacity);
}

API Reference

BsRadio

BsRadioGroup

TRadioInputProps

PropertyTypeDescription
value requiredString|NumberThe <bs-radio> value.
label requiredStringThe <bs-radio> label.
colorStringThe <bs-radio> color appearance. Updated in v2.2.0
Built-in color variants are: default, primary, secondary, success, warning, danger and info.
disabledBooleanCreate <bs-radio> in disabled state.
readonlyBooleanCreate <bs-radio> in readonly state.
idStringSets the <bs-radio> element ID attribute. This property value is auto generates.
nameBooleanSets the <bs-radio> element name attribute.

Released under the BSD-3-Clause License.