Radio groups are used to group multiple radios or radio buttons so they function as a single form control.
Radio groups are used to group multiple radios so they function as a single form control.
Add descriptive help text to a radio group with the help-text attribute. For help texts that contain HTML, use the help-text slot instead.
Use the required attribute to specify the input is a required field when using within a form.
Use the disabled attribute to disable the entire group of radio buttons. You can also disable individual radios as shown here .
Use the error-text attribute to customize the error message shown. Read more about error validation here .
You can listen for the ods-input event to determine when an input is updated. To see other input events check out the events below . You can also see how inputs are used in forms by checking out the form section .
import '@ods/components/web.radio-group';Note: You only need to import a web component once in your code, as it registers itself globally when defined, allowing you to use it anywhere within your application without needing to re-import it each time you want to use the component.
This component is still in development and cannot be imported at this time.
| Name | Description |
|---|---|
| (default) | The default slot where `<ods-radio>` elements are placed. |
| label | The radio group's label. Required for proper accessibility. Alternatively, you can use the `label` attribute. |
| help-text | Text that describes how to use the radio group. Alternatively, you can use the `help-text` attribute. |
Please note, both DOM properties and HTML attributes are shown in the table below. Unless otherwise specified, the property and attribute names are identical.
| Property/Attribute | Reflects | Type | Default |
|---|---|---|---|
defaultValue | string | '' | |
label | string | '' | |
helpText | string | '' | |
errorText | string | '' | |
name | string | 'option' | |
value | string | '' | |
size | 'small' | 'medium' | 'large' | 'medium' | |
disabled | boolean | false | |
form | string | '' | |
required | boolean | false | |
validity | |||
validationMessage |
| React Event | Description | Event Detail |
|---|---|---|
| ods-change | Emitted when the radio group's selected value changes. | -- |
| ods-input | Emitted when the radio group receives user input. | -- |
| ods-invalid | Emitted when the form control has been checked for validity and its constraints aren't satisfied. | -- |
| Name | Description | Arguments |
|---|---|---|
| checkValidity() | Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. | -- |
| getForm() | Gets the associated form, if one exists. | -- |
| reportValidity() | Checks for validity and shows the browser's validation message if the control is invalid. | -- |
| setCustomValidity() | Sets a custom validation message. Pass an empty string to restore validity. | -- |
| Name | Description |
|---|---|
| form-control | The form control that wraps the label, input, and help text. |
| form-control-label | The label's wrapper. |
| form-control-input | The input's wrapper. |
| form-control-help-text | The help text's wrapper. |
| form-control-error-text | The error text's wrapper. |
| button-group | The button group that wraps radio buttons. |
| button-group__base | The button group's `base` part. |
This component automatically imports the following dependencies.
Include intuitive labels with radio groups.
When tabbing, focus will fall on the first option if no options are selected. If there is a selection, focus will fall on that option first.