import React, { Fragment, PureComponent } from 'react'; import PropTypes from 'prop-types'; import { withStyles } from '@material-ui/core/styles'; import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank'; import CheckBoxIcon from '@material-ui/icons/CheckBox'; import Favorite from '@material-ui/icons/Favorite'; import FavoriteBorder from '@material-ui/icons/FavoriteBorder'; import { green } from '@material-ui/core/colors'; import { Checkbox, Typography, Grid, FormControl, FormLabel, FormControlLabel, FormHelperText, FormGroup, } 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], }, }, checked: {}, size: { width: 40, height: 40, }, sizeIcon: { fontSize: 20, }, }); class Checkboxes extends PureComponent { state = { checkedA: true, checkedB: true, checkedF: true, checkedG: true, gilad: true, jason: false, antoine: true, }; handleChange = name => event => { this.setState({ [name]: event.target.checked }); }; render() { const { classes } = this.props; return ( Basic usage
Checkbox with label Checkbox can also be used with a label description thanks to the FormControlLabel component.
)} label="Secondary" /> )} label="Primary" /> } label="Uncontrolled" /> } label="Disabled" /> } label="Disabled" /> )} label="Indeterminate" /> )} label="Custom color" /> } checkedIcon={} value="checkedH" /> } label="Custom icon" /> } checkedIcon={} value="checkedI" /> )} label="Custom size" />
Checkbox in Form Group FormGroup is a helpful wrapper used to group selection controls components that provides an easier API.
Assign responsibility )} label="Gilad Gray" /> )} label="Jason Killian" /> )} label="Antoine Llorca" /> Be careful
); } } Checkboxes.propTypes = { classes: PropTypes.object.isRequired, }; export default withStyles(styles)(Checkboxes);