Is it possible to target a styled JSS object within another styled JSS object in a similar way that styled components allows?
Here's an example of what I'm talking about with Styled Components:
const Child = styled.div` color: red; `; const Parent = styled.div` display: flex; ${Child}:hover { color: blue } `;
Is this possible in JSS?
Fyi I'm using Material UI v4's styling solution which is based off JSS.
use the & ampersands along with brackets [] for accomplish that in JSS:
[]
JSS
const Child = styled(div)({ color: 'red', }); const Parent = styled(div)({ display: 'flex', [`& ${Child}:hover`]: { color: 'blue' } });
2.1m questions
2.1m answers
60 comments
57.0k users