Configuration object
Name of the component
Label text or a function that receives params with data and value, returning a promise of label
Array of option texts or a function that receives params with data and value, returning a promise of options
If true, the field is required
True or false or a function that receives params with data and value, returning a promise of boolean
If false/undefined the field is valid. If a string is provided, it will be used as the validation message, or a function that returns validation state
Hint message to display below the field or a function that receives params with data and value, returning a promise of hint message
True or false or a function that receives params with data and value, returning a promise of boolean
Basic usage with required props
segmentedField({
name: 'status',
label: 'Status',
items: [
{ value: 'active', label: 'Active' },
{ value: 'inactive', label: 'Inactive' },
{ value: 'pending', label: 'Pending' }
]
});
Usage with async props depending on other fields and field value
segmentedField({
name: 'priority',
label: async ({data}) => `Priority Level (${data.userType})`,
items: async ({data}) =>
data.userType === 'premium'
? [
{ value: 'low', label: 'Low Priority' },
{ value: 'medium', label: 'Medium Priority' },
{ value: 'high', label: 'High Priority' }
]
: [
{ value: 'low', label: 'Low' },
{ value: 'medium', label: 'Medium' }
],
invalid: async ({data, value}) =>
data.required && !value ? 'Please select a priority' : false
});
Segmented field component for single selection from multiple options. Supports both static and dynamic props based on current state.