Radio

Radio buttons allow the user to select one option from a set.

<Radio />

Props

PropTypeDefaultDescription
checkedboolIf true, the component is checked.
checkedIconnodeThe icon to display when the component is checked.
classesobjectOverride or extend the styles applied to the component. See CSS API below for more details.
disabledboolIf true, the radio will be disabled.
disableRippleboolIf true, the ripple effect will be disabled.
iconnodeThe icon to display when the component is unchecked.
idstringThe id of the input element.
inputPropsobjectAttributes applied to the input element.
inputRefrefPass a ref to the input element.
namestringName attribute of the input element.
onChangefuncCallback fired when the state is changed. Signature: function(event: object) => void event: The event source of the callback. You can pull out the new value by accessing event.target.value (string). You can pull out the new checked state by accessing event.target.checked (boolean).
requiredboolIf true, the input element will be required.
size'medium' | 'small''medium'The size of the radio. small is equivalent to the dense radio styling.
valueanyThe value of the component. The DOM API casts this to a string.

The ref is forwarded to the root element.

Any other props supplied will be provided to the root element (IconButton).

Examples

Disabled Radio

() => {
const [value, setValue] = React.useState('disabled1');
const handleChange = (event) => {
setValue(event.target.value);
};
return (
<FormControl component="fieldset">
<FormLabel component="legend">Disabled Options</FormLabel>
<RadioGroup
aria-label="disabled options"
name="disabled options"
value={value}
onChange={handleChange}
>
<FormControlLabel
value="disabled1"
disabled
control={<Radio />}
label="Selected disabled option"
/>
<FormControlLabel
value="disabled2"
disabled
control={<Radio />}
label="Unselected disabled option"
/>
</RadioGroup>
</FormControl>
);
};

RadioGroup

() => {
const [value, setValue] = React.useState('female');
const handleChange = (event) => {
setValue(event.target.value);
};
return (
<FormControl component="fieldset">
<FormLabel component="legend">Gender</FormLabel>
<RadioGroup
aria-label="gender"
name="gender1"
value={value}
onChange={handleChange}
>
<FormControlLabel value="female" control={<Radio />} label="Female" />
<FormControlLabel value="male" control={<Radio />} label="Male" />
<FormControlLabel value="other" control={<Radio />} label="Other" />
<FormControlLabel
value="disabled"
disabled
control={<Radio />}
label="(Disabled option)"
/>
</RadioGroup>
</FormControl>
);
};

Standalone Radio buttons

() => {
const [selectedValue, setSelectedValue] = React.useState('a');
const handleChange = (event) => {
setSelectedValue(event.target.value);
};
return (
<div>
<Radio
checked={selectedValue === 'a'}
onChange={handleChange}
value="a"
name="radio-button-demo"
inputProps={{ 'aria-label': 'A' }}
/>
<Radio
checked={selectedValue === 'b'}
onChange={handleChange}
value="b"
name="radio-button-demo"
inputProps={{ 'aria-label': 'B' }}
/>
<Radio
checked={selectedValue === 'c'}
onChange={handleChange}
value="c"
name="radio-button-demo"
inputProps={{ 'aria-label': 'C' }}
/>
<Radio
checked={selectedValue === 'd'}
onChange={handleChange}
value="d"
name="radio-button-demo"
inputProps={{ 'aria-label': 'D' }}
/>
<Radio
checked={selectedValue === 'e'}
onChange={handleChange}
value="e"
name="radio-button-demo"
inputProps={{ 'aria-label': 'E' }}
size="small"
/>
</div>
);
};