Radio Group

A radio group let the user make a mutually exclusive selection from a group of options.


defaultValue: stringInitial value of the radio group, only when it is uncontrolled.
value: stringValue of the radio group. If undefined, the component will be uncontrolled and the value will be managed internally by the component.
label: stringText to be placed above the radio group.
name: stringName attribute of the input element. This attribute will allow users to find the component's value during the submit event.
options: Option[]An array of objects representing the selectable options. Each object Option has the following properties:
  • label: string: Label of the option placed next to the radio input.
  • value: string: Value of the option. It should be unique and not an empty string, which is reserved to the optional item added by optional prop.
  • disabled: boolean: disables the option.
helperText: stringHelper text to be placed above the radio group.
disabled: booleanfalseIf true, the component will be disabled.
optional: booleanfalseIf true, the radio group will be optional, showing (Optional) next to the label and adding a default last option with an empty string as value. Otherwise, the field will be considered required and an error will be passed as a parameter to the OnBlur functions if an option wasn't selected.
optionalItemLabel: string"N/A"Label of the optional radio input.
readonly: booleanfalseIf true, the component will be marked as readonly.
stacking: "row" | "column""column"Sets the orientation of the options within the radio group.
onChange: functionThis function will be called when the user chooses an option. The new value will be passed to this function.
onBlur: functionThis function will be called when the radio group loses the focus. An object including the value and the error will be passed to this function. An example of this object is: { value: value, error: error }. If there is no error, error will not be defined.
error: stringIf it is a defined value and also a truthy string, the component will change its appearance, showing the error below the radio group. If the defined value is an empty string, it will reserve a space below the component for a future error, but it would not change its look. In case of being undefined or null, both the appearance and the space for the error message would not be modified.
tabIndex: number0Value of the tabindex attribute.
ref: objectReference to the component.




Error handling

For handling errors, we suggest initializing the error prop with an empty string. This will reserve space for a possible future error message and prevent unintended layout changes. Also, the onBlur event will send undefined when there is no error, so you may also need to control this too to avoid the same problem.