I have a core-menu with a few core-submenus (each is itself an accordion submenu) beneath it. Each submenu has an icon and a label, defined in the submenu's attribute markup. Is there a way I can set different colors for the icon and the label? Is there a better way to achieve what I'm trying to do?
You can see what I've tried below.
<style>
core-submenu {
color: red;
}
core-submenu::shadow [icon="maps:local-hospital"] {
color: blue;
}
core-submenu::shadow [icon="editor:attach-money"] {
color: green;
}
</style>
<core-menu>
<core-submenu icon="maps:local-hospital" label="Benefits">
<core-item label="Hospitals"></core-item>
<core-item label="Clinics"></core-item>
</core-submenu>
<core-submenu icon="editor:attach-money" label="Money">
<core-item label="Banks"></core-item>
<core-item label="ATMs"></core-item>
</core-submenu>
</core-menu>
Note that I looked at this post on core-submenu styling and this post on core-submenu styling in Firefox but found neither helpful for this situation.
As mentioned in the first post that you link to:
Your selector currently targets an element with the
iconattribute within thecore-submenu's shadow tree. That's not correct, sinceiconattribute is on thecore-submenuelement itself, andcore-iconelement, not an element with theiconattribute.You need to combine the attribute selector with the
core-submenutype selector and its::shadowpseudo-element, and target the icon within the submenu item's shadow tree with an additional::shadowpseudo-element, like so: