Skip to main content

Radio buttons

Single radio button props

NameTypeDefaultDescription
labelstring-The label displayed next to the radio button.
namestring-The name of field being registerd.
valuestring-The value assigned to the radio button.
isDisabledboolean-Disables the radio button when true.
dataTestIdstring''A data-testid attribute for testing purposes.

Radio buttons group props

NameTypeDefaultDescription
fieldsArray<TRadioButton>[]Array of objects representing the properties for individual radio buttons.
labelstring-The label displayed for the component. If component is used as a standalone component, it needs to be wrapped with withLabelAndTooltip.
labelConfigobject{ labelClassName: {}, labelTextClassName: {} }Configuration for customizing label styles. If component is used as a standalone component, it needs to be wrapped with withLabelAndTooltip.
idstring-The unique identifier for the component. If component is used as a standalone component, it needs to be wrapped with withLabelAndTooltip.
tooltipstring''Tooltip content to display additional information. If component is used as a standalone component, it needs to be wrapped with withLabelAndTooltip.
dependsOnFieldobject{ fieldName: '', value: [] }Defines dependencies on another field (To show or hide this component,based on state of some field), specifying the field name and expected value(s). If component is used as a standalone component, it needs to be wrapped with withLabelAndTooltip.

Config example

const radioButtonConfig = {
type: 'radio',
data: {
name: 'contactMethod',
label: 'Preferred Contact Method *',
tooltip: 'Choose how you prefer to be contacted.',
fields: [
{
label: 'Email',
value: 'email',
name: 'contactMethod',
id: 'contact-method-email'
},
{
label: 'Phone',
value: 'phone',
name: 'contactMethod',
id: 'contact-method-phone'
},
{
label: 'SMS',
value: 'sms',
name: 'contactMethod',
id: 'contact-method-sms'
}
]
}
}