UNPKG

materialuiupgraded

Version:

Material-UI's workspace package

86 lines (78 loc) 2.26 kB
import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; import green from '@material-ui/core/colors/green'; import Radio from '@material-ui/core/Radio'; import RadioButtonUncheckedIcon from '@material-ui/icons/RadioButtonUnchecked'; import RadioButtonCheckedIcon from '@material-ui/icons/RadioButtonChecked'; const styles = { root: { color: green[600], '&$checked': { color: green[500], }, }, checked: {}, }; class RadioButtons extends React.Component { state = { selectedValue: 'a', }; handleChange = event => { this.setState({ selectedValue: event.target.value }); }; render() { const { classes } = this.props; return ( <div> <Radio checked={this.state.selectedValue === 'a'} onChange={this.handleChange} value="a" name="radio-button-demo" aria-label="A" /> <Radio checked={this.state.selectedValue === 'b'} onChange={this.handleChange} value="b" name="radio-button-demo" aria-label="B" /> <Radio checked={this.state.selectedValue === 'c'} onChange={this.handleChange} value="c" name="radio-button-demo" aria-label="C" classes={{ root: classes.root, checked: classes.checked, }} /> <Radio checked={this.state.selectedValue === 'd'} onChange={this.handleChange} value="d" color="default" name="radio-button-demo" aria-label="D" /> <Radio checked={this.state.selectedValue === 'e'} onChange={this.handleChange} value="e" color="default" name="radio-button-demo" aria-label="E" icon={<RadioButtonUncheckedIcon fontSize="small" />} checkedIcon={<RadioButtonCheckedIcon fontSize="small" />} /> </div> ); } } RadioButtons.propTypes = { classes: PropTypes.object.isRequired, }; export default withStyles(styles)(RadioButtons);