|
| 1 | +# Radio Group |
| 2 | +Set of radio's components |
| 3 | + |
| 4 | +## Example |
| 5 | +<div class="p-3 border rounded-2 my-3"> |
| 6 | + <v-radio-group |
| 7 | + class="mb-3" |
| 8 | + label="Favorite color" |
| 9 | + name="group1" |
| 10 | + v-model="group1" |
| 11 | + :options="['White', 'Red', 'Blue']" |
| 12 | + /> |
| 13 | + |
| 14 | + <v-radio-group |
| 15 | + label="Favorite color" |
| 16 | + name="group2" |
| 17 | + v-model="group2" |
| 18 | + :options="[ |
| 19 | + { id: 1, label: 'White', value: 'white', disabled: false }, |
| 20 | + { id: 2, label: 'Red', value: 'red', disabled: true }, |
| 21 | + { id: 3, label: 'Blue', value: 'blue', disabled: false }, |
| 22 | + ]" |
| 23 | + /> |
| 24 | +</div> |
| 25 | + |
| 26 | +```html |
| 27 | +<!-- Array of strings --> |
| 28 | +<v-radio-group |
| 29 | + label="Favorite color" |
| 30 | + name="group1" |
| 31 | + v-model="group1" |
| 32 | + :options="['White', 'Red', 'Blue']" |
| 33 | +/> |
| 34 | + |
| 35 | +<!-- Array of objects --> |
| 36 | +<v-radio-group |
| 37 | + label="Favorite color" |
| 38 | + name="group2" |
| 39 | + v-model="group2" |
| 40 | + :options="[ |
| 41 | + { id: 1, label: 'White', value: 'white', disabled: false }, |
| 42 | + { id: 2, label: 'Red', value: 'red', disabled: true }, |
| 43 | + { id: 3, label: 'Blue', value: 'blue', disabled: false }, |
| 44 | + ]" |
| 45 | +/> |
| 46 | +``` |
| 47 | + |
| 48 | +## Props |
| 49 | +Name | Type | Description | Default | Required |
| 50 | +---------- | -------- | ----------- | ------- | -------- |
| 51 | +name | String | The name of the radio group. Applied as the `name` attribute on each input element in the radio group | false | true |
| 52 | +label | String | The radio group label | None | false |
| 53 | +value, v-model | [String, Number] | The model that the selected value in the radio group syncs to. Can be set initially for a default selection. If you are not using `v-model`, you should listen for the `input` event and update `value` | None | true |
| 54 | +options | Array | An array of options to show to the user as radio buttons. The array can either be of strings or objects (but not both). | None | true |
| 55 | +keys | Object | Allows for redefining the option keys. The id, class, checked, and disabled keys are optional. Pass an object with custom keys if your data does not match the default keys. Note that if you redefine one key, you have to define all the others as well.| `{id: 'id',label: 'label',value: 'value',checked: 'checked',disabled: 'disabled' }` | false |
| 56 | +tabindex | [String, Number] | The radio group tabindex | None | false |
| 57 | +disabled | Boolean | Whether or not the radio group is disabled | false | false |
| 58 | + |
| 59 | +## Events |
| 60 | +Name | Description |
| 61 | +---------- | ----------- |
| 62 | +@focus | Emitted when a radio button in the group is focused |
| 63 | +@blur | Emitted when a radio button in the group loses focus |
| 64 | +@input | Emitted when the radio group value is changed. The handler is called with the new value |
| 65 | +@change | Emitted when the value of the radio group is changed. The handler is called with the new value |
| 66 | + |
| 67 | +## Methods |
| 68 | +Name | Description |
| 69 | +---------- | ---------- |
| 70 | +reset() | Call this method to reset the radio group's `value` to its initial `value`. |
| 71 | +<script> |
| 72 | +export default { |
| 73 | + data() { |
| 74 | + return { group1: '', group2: '' }; |
| 75 | + }, |
| 76 | +}; |
| 77 | +</script> |
0 commit comments