-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
/
SwitchLabels.js
48 lines (44 loc) · 1.31 KB
/
SwitchLabels.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
import React from 'react';
import FormGroup from '@material-ui/core/FormGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import Switch from '@material-ui/core/Switch';
class SwitchLabels extends React.Component {
state = {
checkedA: true,
checkedB: true,
};
handleChange = name => event => {
this.setState({ [name]: event.target.checked });
};
render() {
return (
<FormGroup row>
<FormControlLabel
control={
<Switch
checked={this.state.checkedA}
onChange={this.handleChange('checkedA')}
value="checkedA"
/>
}
label="Secondary"
/>
<FormControlLabel
control={
<Switch
checked={this.state.checkedB}
onChange={this.handleChange('checkedB')}
value="checkedB"
color="primary"
/>
}
label="Primary"
/>
<FormControlLabel control={<Switch value="checkedC" />} label="Uncontrolled" />
<FormControlLabel disabled control={<Switch value="checkedD" />} label="Disabled" />
<FormControlLabel disabled control={<Switch checked value="checkedE" />} label="Disabled" />
</FormGroup>
);
}
}
export default SwitchLabels;