Configuration object
Name of the component
Label text
Array of options
Default selected value
If true, the field is required
If true, the field is disabled
If false/undefined the field is valid. If a string is provided, it will be used as the validation message
Basic usage with required props
radioList({
name: 'gender',
label: 'Gender',
items: [
{ value: 'male', label: 'Male' },
{ value: 'female', label: 'Female' },
{ value: 'other', label: 'Other' }
]
});
Usage with default value
radioList({
name: 'preferredContact',
label: 'Preferred Contact Method',
items: [
{ value: 'email', label: 'Email' },
{ value: 'phone', label: 'Phone' },
{ value: 'mail', label: 'Mail' }
],
defaultValue: 'email',
required: true,
disabled: false
});
Usage with dynamic items depending on other fields
radioList({
name: 'food',
label: 'Food',
items: async ({data}) =>
data.country === 'us'
? [{value: 'burger', label: 'Burger'}, {value: 'fries', label: 'Fries'}]
: [{value: 'pasta', label: 'Pasta'}, {value: 'pizza', label: 'Pizza'}, {value: 'salad', label: 'Salad'}],
});
Radio list component for single selection from multiple options.