jss-plugin-extend
is not included by default in Material-UI.
You can find the list of included JSS plugins here: https://material-ui.com/styles/advanced/#jss-plugins.
You can follow the instructions for adding additional plugins, but you can also achieve the same effect in other ways.
You can put the common properties in an object:
const commonButton = {
display: "none",
position: "absolute",
fontSize: "24px"
};
export default props => ({
ButtonLeft: {
...commonButton,
left: "0",
},
ButtonRight: {
...commonButton,
right: "0",
}
});
Or since you have a root
rule that the buttons are structurally within, you could apply all the common styles via nested rules in root
:
export default props => ({
root: {
width: "250px",
height: "182px",
alignItems: "center",
justifyContent: "space-between",
border: "1px solid black",
position: "relative",
"& $ButtonLeft, & $ButtonRight": {
display: "none",
position: "absolute",
fontSize: "24px"
},
"&:hover $ButtonLeft, &:hover $ButtonRight": {
display: "block"
}
},
ButtonLeft: { left: "0" },
ButtonRight: { right: "0" }
});
The example above leverages jss-plugin-nested
which is included in Material-UI by default. This also shows the appropriate syntax for the hover
references.
Related answers:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…