InputRadio.vue component is a reusable Vue.js component for creating radio button inputs. It supports two-way binding with v-model for managing the selected value, and it allows customization through props like label, name, value, and disabled.
Features
Custom Labels
Provides descriptive labels for the radio options.
Disabled State
Supports disabling individual radio buttons.
Flexible Design
Allows customization of width through the
width prop.Usage
Basic Example
Here is our working Vue model for the examples:Example with Multiple Options
Props
Binds the selected value of the radio button group.
Controls the width of the radio button component as a percentage.
The label text displayed next to the radio button.
The value of the radio button.
Disables the radio button if set to
true.The name attribute for grouping radio buttons.
Example Use Cases
Form with Radio Group
Use theInputRadio component in a form to select one option from a group:
Disabled Radio Button
Prevent user interaction for specific options:Notes
- Two-Way Binding: The
v-modelprop ensures that the selected value is updated dynamically. - Group Behavior: Use the same
namefor all radio buttons in a group to enforce mutual exclusivity. - Customizable Width: The
widthprop can be adjusted to fit the layout requirements.