import React from 'react'; import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'; import FormLabel from '@material-ui/core/FormLabel'; import FormControl from '@material-ui/core/FormControl'; import FormGroup from '@material-ui/core/FormGroup'; import FormControlLabel from '@material-ui/core/FormControlLabel'; import FormHelperText from '@material-ui/core/FormHelperText'; import Checkbox from '@material-ui/core/Checkbox'; const useStyles = makeStyles((theme: Theme) => createStyles({ root: { display: 'flex', }, formControl: { margin: theme.spacing(3), }, }), ); export default function CheckboxesGroup() { const classes = useStyles(); const [state, setState] = React.useState({ gilad: true, jason: false, antoine: false, }); const handleChange = (event: React.ChangeEvent) => { setState({ ...state, [event.target.name]: event.target.checked }); }; const { gilad, jason, antoine } = state; const error = [gilad, jason, antoine].filter((v) => v).length !== 2; return (
Assign responsibility } label="Gilad Gray" /> } label="Jason Killian" /> } label="Antoine Llorca" /> Be careful Pick two } label="Gilad Gray" /> } label="Jason Killian" /> } label="Antoine Llorca" /> You can display an error
); }