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.
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:
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.
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.
TIP
Any MDBootstrap Color variants and Material Color variants can be applied to the color
property.
CSS Variables
Added since v2.0.0--md-radio-margin: .5rem 1rem .5rem 0;
--md-radio-size: 20px;
--md-radio-stroke: 2px;
--md-radio-touch-size: 40px;
--md-radio-disabled-bg: transparent;
--md-radio-disabled-opacity: calc(var(--md-field-disabled-opacity) - .2);
--md-radio-color: currentColor;
--md-radio-active-color: #{$color};
API Reference
BsRadio
BsRadioGroup
TRadioProps
The TRadioProps has properties as described below:
Property | Type | Description |
---|---|---|
value required | String /Number | The <bs-radio> value. |
label required | String | The <bs-radio> label. |
color | String | The <bs-radio> color appearance. |
disabled | Boolean | Create <bs-radio> in disabled state. |
readonly | Boolean | Create <bs-radio> in readonly state. |
id | String | Sets the <bs-radio> element ID attribute. This property value is auto generates. |
name | Boolean | Sets the <bs-radio> element name attribute. |