-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
/
CheckboxLabels.js
120 lines (113 loc) · 3.15 KB
/
CheckboxLabels.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from 'material-ui/styles';
import green from 'material-ui/colors/green';
import { FormGroup, FormControlLabel } from 'material-ui/Form';
import Checkbox from 'material-ui/Checkbox';
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';
const styles = {
checked: {
color: green[500],
},
size: {
width: 40,
height: 40,
},
sizeIcon: {
fontSize: 20,
},
};
class CheckboxLabels extends React.Component {
state = {
checkedA: true,
checkedB: true,
checkedF: true,
checkedG: true,
};
handleChange = name => event => {
this.setState({ [name]: event.target.checked });
};
render() {
const { classes } = this.props;
return (
<FormGroup row>
<FormControlLabel
control={
<Checkbox
checked={this.state.checkedA}
onChange={this.handleChange('checkedA')}
value="checkedA"
/>
}
label="Secondary"
/>
<FormControlLabel
control={
<Checkbox
checked={this.state.checkedB}
onChange={this.handleChange('checkedB')}
value="checkedB"
color="primary"
/>
}
label="Primary"
/>
<FormControlLabel control={<Checkbox value="checkedC" />} label="Uncontrolled" />
<FormControlLabel disabled control={<Checkbox value="checkedD" />} label="Disabled" />
<FormControlLabel
disabled
control={<Checkbox checked value="checkedE" />}
label="Disabled"
/>
<FormControlLabel
control={
<Checkbox
checked={this.state.checkedF}
onChange={this.handleChange('checkedF')}
value="checkedF"
indeterminate
/>
}
label="Indeterminate"
/>
<FormControlLabel
control={
<Checkbox
checked={this.state.checkedG}
onChange={this.handleChange('checkedG')}
value="checkedG"
classes={{
checked: classes.checked,
}}
/>
}
label="Custom color"
/>
<FormControlLabel
control={
<Checkbox icon={<FavoriteBorder />} checkedIcon={<Favorite />} value="checkedH" />
}
label="Custom icon"
/>
<FormControlLabel
control={
<Checkbox
className={classes.size}
icon={<CheckBoxOutlineBlankIcon className={classes.sizeIcon} />}
checkedIcon={<CheckBoxIcon className={classes.sizeIcon} />}
value="checkedI"
/>
}
label="Custom size"
/>
</FormGroup>
);
}
}
CheckboxLabels.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withStyles(styles)(CheckboxLabels);