<Radio />
Prop | Type | Default | Description |
---|---|---|---|
checked | bool | If true, the component is checked. | |
checkedIcon | node | The icon to display when the component is checked. | |
classes | object | Override or extend the styles applied to the component. See CSS API below for more details. | |
disabled | bool | If true, the radio will be disabled. | |
disableRipple | bool | If true, the ripple effect will be disabled. | |
icon | node | The icon to display when the component is unchecked. | |
id | string | The id of the input element. | |
inputProps | object | Attributes applied to the input element. | |
inputRef | ref | Pass a ref to the input element. | |
name | string | Name attribute of the input element. | |
onChange | func | Callback 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). | |
required | bool | If true, the input element will be required. | |
size | 'medium' | 'small' | 'medium' | The size of the radio. small is equivalent to the dense radio styling. |
value | any | The 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).
() => {const [value, setValue] = React.useState('disabled1');const handleChange = (event) => {setValue(event.target.value);};return (<FormControl component="fieldset"><FormLabel component="legend">Disabled Options</FormLabel><RadioGrouparia-label="disabled options"name="disabled options"value={value}onChange={handleChange}><FormControlLabelvalue="disabled1"disabledcontrol={<Radio />}label="Selected disabled option"/><FormControlLabelvalue="disabled2"disabledcontrol={<Radio />}label="Unselected disabled option"/></RadioGroup></FormControl>);};
() => {const [value, setValue] = React.useState('female');const handleChange = (event) => {setValue(event.target.value);};return (<FormControl component="fieldset"><FormLabel component="legend">Gender</FormLabel><RadioGrouparia-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" /><FormControlLabelvalue="disabled"disabledcontrol={<Radio />}label="(Disabled option)"/></RadioGroup></FormControl>);};
() => {const [selectedValue, setSelectedValue] = React.useState('a');const handleChange = (event) => {setSelectedValue(event.target.value);};return (<div><Radiochecked={selectedValue === 'a'}onChange={handleChange}value="a"name="radio-button-demo"inputProps={{ 'aria-label': 'A' }}/><Radiochecked={selectedValue === 'b'}onChange={handleChange}value="b"name="radio-button-demo"inputProps={{ 'aria-label': 'B' }}/><Radiochecked={selectedValue === 'c'}onChange={handleChange}value="c"name="radio-button-demo"inputProps={{ 'aria-label': 'C' }}/><Radiochecked={selectedValue === 'd'}onChange={handleChange}value="d"name="radio-button-demo"inputProps={{ 'aria-label': 'D' }}/><Radiochecked={selectedValue === 'e'}onChange={handleChange}value="e"name="radio-button-demo"inputProps={{ 'aria-label': 'E' }}size="small"/></div>);};