Radio button

Radio buttons select exactly one option from a set.

A list of three options with radio buttons; the second is selected.

View interactive demo inline.

Open interactive demo in new tab.

Radios behave like <input type="radio"> elements and form a group with the same name attribute. Only one radio can be selected in a group.

Radios can be pre-selected by adding a checked attribute.

Add a value to identify which radio is selected in a form.

<form>
  <petal-radio name="animals" value="cats"></petal-radio>
  <petal-radio name="animals" value="dogs"></petal-radio>
  <petal-radio name="animals" value="birds" checked></petal-radio>
</form>

Associate a label with a radio using the <label> element.

<petal-radio id="cats-radio" name="animals" value="cats"></petal-radio>
<label for="cats-radio">Cats</label>

<petal-radio id="dogs-radio" name="animals" value="dogs"></petal-radio>
<label for="dogs-radio">Dogs</label>
bookmark

do not wrap radios inside of a <label>, which stops screen readers from correctly announcing the number of radios in a group.

Add an aria-label attribute to radios without labels or radios whose labels need to be more descriptive.

Place radios inside a role="radiogroup". Radio groups must display a label, either with aria-label or aria-labelledby.

<div role="radiogroup" aria-labelledby="group-title">
  <h3 id="group-title">Starting position</h3>
  <div>
    <petal-radio id="first-radio" name="group" value="1"
        aria-label="First"></petal-radio>
    <label for="first-radio">1st</label>
  </div>
  <div>
    <petal-radio id="second-radio" name="group" value="2"
        aria-label="Second"></petal-radio>
    <label for="second-radio">2nd</label>
  </div>
</div>
bookmark

radios are not automatically labelled by <label> elements and always need an aria-label. See b/294081528.

Radios support Material theming and can be customized in terms of color.

TokenDefault value
--md-radio-icon-color--md-sys-color-on-surface-variant
--md-radio-selected-icon-color--md-sys-color-primary
--md-radio-icon-size20px
<style>
:root {
  --md-sys-color-primary: #006A6A;
  --md-radio-icon-size: 16px;
}
</style>

<petal-radio name="group"></petal-radio>
<petal-radio name="group" checked></petal-radio>
<petal-radio name="group"></petal-radio>
PropertyAttributeTypeDefaultDescription
requiredrequiredbooleanfalseWhether or not the radio is required. If any radio is required in a group, all radios are implicitly required.
valuevaluestring'on'The element value to use in form submission when checked.
checkedcheckedbooleanundefined
namenamestringundefinedThe HTML name to use in form submission.
disableddisabledbooleanundefinedWhether or not the element is disabled.
formHTMLFormElementundefinedThe associated form element with which this element's value will submit.
labelsNodeListundefinedThe labels this element is associated with.
validityValidityStateundefinedReturns a ValidityState object that represents the validity states of the element.
https://developer.mozilla.org/en-US/docs/Web/API/ValidityState
validationMessagestringundefinedReturns a validation error message or an empty string if the element is valid.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage
willValidatebooleanundefinedReturns whether an element will successfully validate based on forms validation rules and constraints.
Disabled and readonly elements will not validate.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
MethodParametersReturnsDescription
formResetCallbackNonevoid
formStateRestoreCallbackstatevoid
checkValidityNonebooleanChecks the element's constraint validation and returns true if the element is valid or false if not.
If invalid, this method will dispatch an invalid event.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity
reportValidityNonebooleanChecks the element's constraint validation and returns true if the element is valid or false if not.
If invalid, this method will dispatch a cancelable invalid event. If not canceled, a the current validationMessage will be reported to the user.
https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity
setCustomValidityerrorvoidSets the element's constraint validation error message. When set to a non-empty string, validity.customError will be true and validationMessage will display the provided error.
Use this method to customize error messages reported.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
EventTypeBubblesComposedDescription
inputInputEventYesNoDispatched when the value changes from user interaction.
changeEventYesYesDispatched when the value changes from user interaction.
About
IntroductionQuick StartMaterial 3 ExpressiveRoadmapSupportBundle SizesDesign tokensToken update v34LicensingVisual testingReleasing
Theming
Material ThemingColorTypographyShape
Components
Button groupButtonsCheckboxChipsDialogsFloating action button (FAB)Icon ButtonsListsMenusProgress indicatorsRadioRippleSelectSlidersSwitchTabsText field