Hi @RolandLocke - welcome to the forum!
I merged your question into this post, to keep them together for future readers.
Yea hook_page_attachments()
or hook_page_attachments_alter()
is another way to do it!
The basic principle is the same: you want to use a Drupal hook (a specially named function) to attach your library (CSS) to all pages that have the menu, so that it gets included and styles the icon the way you want. There are various hooks that could be used for this purpose, and the āpage attachmentsā ones work because they essentially run on every page load, so youāre pretty guaranteed to get your code included everywhere you need it.
Using a preprocess hook, as described earlier, is a more ātargetedā way of doing the same thing. Essentially, instead of saying āadd this CSS to every pageā, a preprocess hook can say āadd this CSS whenever the toolbar is built.ā The toolbar is ultimately what youāre trying to modify, so using hook_preprocess_toolbar()
is probably the ābestā way to do it, but both will work.
Iām not sure why @SirSundaysās hook wasnāt working, but here is another example in a community module that uses hook_preprocess_toolbar()
, and I know for a fact that this works:
That adds this library: farm_regen_digital/farm_regen_digital.libraries.yml at 1.x Ā· Regen-Digital/farm_regen_digital Ā· GitHub
⦠which adds this CSS: farm_regen_digital/css/toolbar.css at 1.x · Regen-Digital/farm_regen_digital · GitHub
Note: that CSS does two things⦠adjusts the logo size and spacing (because the module also replaces the default farmOS logo), and it styles the āIntegrationsā icon (on a related note, we are considering moving this āIntegrationsā menu item into core: Integrations menu?).
Hope that helps!