Last active
January 31, 2020 14:30
-
-
Save Goloburda/c170ee9428112ee245926066a1a782d8 to your computer and use it in GitHub Desktop.
withStyles Material UI.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Component to style doc: https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Switch/Switch.js | |
import Switch from "@material-ui/core/Switch"; | |
import styled from "styled-components"; | |
import { withStyles } from "@material-ui/core/styles"; | |
const StyledSwitch = styled(Switch)` | |
.MuiSwitch-colorSecondary { | |
color: green; | |
:hover { | |
background: red; | |
} | |
} | |
.MuiSwitch-colorSecondary.Mui-checked + .MuiSwitch-track { | |
background: green; | |
opacity: 1; | |
} | |
.MuiSwitch-colorSecondary + .MuiSwitch-track { | |
background: black; | |
opacity: 1; | |
} | |
.MuiSwitch-colorSecondary.Mui-checked { | |
color: black; | |
} | |
`; | |
const WithStyledSwitch = withStyles({ | |
switchBase: { | |
color: "blue", | |
"&:hover": { | |
background: "red", | |
color: "white" | |
}, | |
"&$checked + $track": { | |
color: "black", | |
backgroundColor: "pink", | |
opacity: 1 | |
} | |
}, | |
colorSecondary: { | |
"&$checked": { | |
color: "pink", | |
"&:hover": { | |
background: "transparent" | |
} | |
} | |
}, | |
checked: {}, | |
disabled: {}, | |
track: { | |
background: "blue", | |
opacity: 1 | |
} | |
})(Switch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment