I'm using react-jss component. Here's my sample code:
<ul>
<li className={classNames(classes.listStyleNone)}>Item 1</li>
<li className={classNames(classes.listStyleNone)}>Item 2</li>
<li className={classNames(classes.listStyleNone)}>Item 3</li>
</ul>
and my code in style.js is:
const styles = theme => ({
listStyleNone: {
listStyle: 'none',
},
})
Is there a way I add just a class to ul element and style it's children elements with that in react-jss component? like this:
.listStyleNone > li {list-style: none;}
To pass styles to child component and use it as scoped style in Vue. js, we can use the deep selector. to add the deep select with >>> , /deep/ or ::v-deep . They all select the b select in a .
Styled Components is on version 5 and JSS is on version 10. Most of the significant bugs and limitations have been worked out by now. As far as the code goes, pretty much anything you desire to accomplish can be accomplished with either library.
Thanks all, However for list-style it's working but for other css like padding: 10px; it's not. So here's a better way:
<ul className={classNames(classes.listStyleNone)}>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
const styles = theme => ({
listStyleNone: {
'& li':{
listStyle: 'none';
}
},
})
Please see following code snippet. I hope it will help you clearly.
parent: {
textAlign: 'center',
'& div': {
padding: 15,
'&:hover': {
color: 'yellow',
}
}
}
Here is the codepen link. If child elements of parent, will have a padding with 15px. If you hover those div tags, text color changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With