How to declare a variant on component root element but style a sub-element?
.component.variantThe selector you want to insert .elementThe element you want to style
- SASS
+component('.btn')
+register
+variant('.primary')
+element('.icon')
display: inline-flex
+___________________
+element('.icon')
+default
background-color: grey
+variant('.primary')
background-color: red
- CSS
.btn {
display: inline-flex;
}
.btn .icon {
background-color: grey;
}
.btn.primary .icon {
background-color: red;
}
More info: +state, +default, +element, +register, +component, separator +___