@@ -32,35 +32,96 @@ semantic and accessible markup, so it is a solid replacement for the default rad
32
32
export default {
33
33
data: {
34
34
selected: ' first' ,
35
- options: [{
36
- text: ' Toggle this custom radio' ,
37
- value: ' first'
38
- }, {
39
- text: ' Or toggle this other custom radio' ,
40
- value: ' second'
41
- }, {
42
- text: ' This one is Disabled' ,
43
- value: ' third' ,
44
- disabled: true
45
- }]
35
+ options: [
36
+ { text: ' Toggle this custom radio' , value: ' first' },
37
+ { text: ' Or toggle this other custom radio' , value: ' second' },
38
+ { text: ' This one is Disabled' , value: ' third' , disabled: true }
39
+ ]
46
40
}
47
41
}
48
42
</script >
49
43
50
- <!-- form-radio.vue -->
44
+ <!-- form-radio-1 .vue -->
51
45
```
52
46
53
47
### Options
54
48
55
- Please see options in [ ` <b-form-select> ` ] ( ./form-select ) docs for details on passing options
56
- to ` <b-form-radio> `
49
+ Please see options in [ ` <b-form-select> ` ] ( ./form-select ) docs for details on passing
50
+ options (value array) to ` <b-form-radio> `
57
51
52
+ ### Size
53
+ Control the size of the radio text by setting the prop ` size ` to either ` sm ` for small or
54
+ ` lg ` for large.
58
55
59
56
### Inline or stacked
60
57
By default ` <b-form-radio> ` generates inline radio inputs. Set the prop ` stacked ` to make
61
58
the radios appear one over the other.
62
59
63
60
61
+ ### Button style radios
62
+ Render radios with the look of buttons by setting the prop ` buttons ` . Set the button variant by
63
+ setting the ` button-variant ` prop to one of the standard Bootstrap button variants (see
64
+ [ ` <b-button> ` ] ( ./button ) for supported variants). The default ` button-variant ` is ` secondary ` .
65
+
66
+ The ` buttons ` prop has precedence over ` plain ` , and ` button-variant ` has no effect if
67
+ ` buttons ` is not set.
68
+
69
+ Button style radios will have the class ` .active ` automatically applied to their label
70
+ when they are in the checked state.
71
+
72
+ ``` html
73
+ <template >
74
+ <div >
75
+ <h5 >Button style radios</h5 >
76
+ <b-form-radio id =" btnradios1"
77
+ buttons
78
+ v-model =" selected"
79
+ :options =" options"
80
+ ></b-form-radio >
81
+ <br >
82
+
83
+ <h5 >Button style radios with <code >primary</code > variant and size <code >lg</code ></h5 >
84
+ <b-form-radio id =" btnradios2"
85
+ buttons
86
+ button-variant =" primary"
87
+ size =" lg"
88
+ v-model =" selected"
89
+ :options =" options"
90
+ ></b-form-radio >
91
+ <br >
92
+
93
+ <h5 >Stacked button style radios</h5 >
94
+ <b-form-radio id =" btnradios3"
95
+ buttons
96
+ stacked
97
+ v-model =" selected"
98
+ :options =" options"
99
+ ></b-form-radio >
100
+ <hr >
101
+
102
+ <div >
103
+ Selected: <strong >{{ selected }}</strong >
104
+ </div >
105
+ </div >
106
+ </template >
107
+
108
+ <script >
109
+ export default {
110
+ data: {
111
+ selected: ' radio1' ,
112
+ options: [
113
+ { text: ' Radio 1' , value: ' radio1' },
114
+ { text: ' Radio 3' , value: ' radio2' },
115
+ { text: ' Radio 3 (disabled)' , value: ' radio3' , disabled: true },
116
+ { text: ' Radio 4' , value: ' radio4' }
117
+ ]
118
+ }
119
+ }
120
+ </script >
121
+
122
+ <!-- form-radio-2.vue -->
123
+ ```
124
+
64
125
### Contextual States
65
126
Bootstrap includes validation styles for danger, warning, and success states on most form controls.
66
127
@@ -76,6 +137,8 @@ To apply one of the contextual states on `b-form-radio`, set the `state` prop
76
137
to ` danger ` , ` warning ` , or ` success ` . You may also wrap ` <b-form-radio> ` in a
77
138
` <b-form-fieldset> ` and set the contextual ` state ` prop on ` <b-form-fieldset> ` instead.
78
139
140
+ ** Note:** contextual state is not supported for radios rendered in ` buttons ` mode.
141
+
79
142
#### Conveying contextual validation state to assistive technologies and colorblind users:
80
143
Using these contextual states to denote the state of a form control only provides
81
144
a visual, color-based indication, which will not be conveyed to users of assistive
@@ -98,3 +161,6 @@ Supported `invalid` values are:
98
161
99
162
### Non custom radio inputs
100
163
You can have ` b-form-radio ` render a browser native radio input by setting the ` plain ` prop.
164
+
165
+ ** Note:** ` plain ` will have no effect if ` buttons ` is set.
166
+
0 commit comments