import React, { Fragment, PureComponent } from 'react'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; import RadioButtonUncheckedIcon from '@material-ui/icons/RadioButtonUnchecked'; import RadioButtonCheckedIcon from '@material-ui/icons/RadioButtonChecked'; import { green } from '@material-ui/core/colors'; import { Radio, RadioGroup, Typography, Grid, FormControl, FormLabel, FormControlLabel, FormHelperText, } from '@material-ui/core'; const styles = theme => ({ demo: { height: 'auto', }, divider: { display: 'block', margin: `${theme.spacing(3)}px 0`, }, field: { margin: `${theme.spacing(3)}px 5px`, }, root: { color: green[600], '&$checked': { color: green[500], }, }, formControl: { margin: theme.spacing(3), }, group: { margin: `${theme.spacing(1)}px 0`, }, checked: {}, size: { width: 40, height: 40, }, sizeIcon: { fontSize: 20, }, }); class RadioButton extends PureComponent { state = { value: 'female', selectedValue: 'a', }; handleChange = event => { this.setState({ value: event.target.value }); }; handleChangeOther = event => { this.setState({ selectedValue: event.target.value }); }; render() { const { classes } = this.props; return ( Basic usage Radio buttons should have the most commonly used option selected by default.
Gender } label="Female" /> } label="Male" /> } label="Other" /> } label="(Disabled option)" /> Gender } label="Male" /> } label="Female" /> } label="Other" /> } label="(Disabled option)" /> You can display an error
Radio without label Radio can also be used standalone, without the wrapper. } checkedIcon={} />
); } } RadioButton.propTypes = { classes: PropTypes.object.isRequired, }; export default withStyles(styles)(RadioButton);