This is not a component that should replace card-mod in any way or form, but rather compliment it. With card-mod you can customize individual cards, while with global mod you can mod elements outside of those cards. Styling is done through theme files. So with an additional default-global.mod.yaml theme file:
Where the mod is applied based on your URL location. And with some clever styling you can even remove the action items and add an image as your dashboard title, like so:
even supporting both light and dark modes out of the box . I have even more examples in the repository readme.
Installation can be done through a custom repository from HACS or of course manually. DOM navigation is done the same way as card-mod, where $ substitutes shadow DOM. Also reload themes and refresh your browser for changes to have effect.
This is still very much alpha software and things could break with release. I’m just happy to share now I have been running it myself for over a month now without any obvious drawbacks.
Nou, does this add CSS to any element at the elements itself? So could this be used to overwrite hard coded CSS styles? For example, the hardcoded “Roboto” font in the config/entities data-tables? Or, for example the hardcoded “Roboto”-font in the notifications-drawer?
So could this be used to overwrite hard coded CSS styles? For example, the hardcoded “Roboto” font in the config/entities data-tables? Or, for example the hardcoded “Roboto”-font in the notifications-drawer?
If your theme is bronx and is located in bronx.yaml in the themes directory you should create a new file called bronx-global-mod.yaml*. That file should contain the following:
So mind the missing pipe and the indentation. After that you should reload your themes and refresh your browser to get it working.
You can check whether the theme is loaded by going to your Profile page and see if the bronx-global-mod theme is there. In my case there is the default-global-mod theme:
The easiest way to get started (or test whether global mod is actually loaded) is to add the Basic Example from my GitHub repository as default-global-mod.yaml in your themes directory and select the default theme. If you reload themes and refresh your browser you should have a yellow sidebar.
* Sidenote, you can probably also append a new YAML document to the end of bronx.yaml, but let’s tackle this one step at a time.
Thank you for your reply. I misunderstood the readme, or didn’t grasp the idea.
Now things work, when I select the bronx-gloabl-mod theme in the profile page. Although, how should I copy all the normal overridden CSS selectors from my bronx.yaml theme-file and combine them together with the bronx-global-mod.yaml file?
Hello, can we also use this to change the column width on all device pages.
I would like to change the column width so that not all characters are always cut off, see screenshot.
Absolute path to the element: home-assistant-main//ha-drawer/partial-panel-resolver/ha-panel-config/ha-config-devices/ha-config-device-page//hass-subpage/div
You tried to traverse to a shadow root between ha-panel-config and ha-config-devices, and between ha-config-devices and ha-config-device-page, but those were just regular descendants. Therefore those should only be separated by a space instead of a dollar sign.
The selector went one level too deep. The final $div isn’t necessary. Otherwise the custom mod style is created within the div.container. But styles are scoped within elements. So it should be scoped on the same level as the div.
Thank you very much. Thanks to your help, I’ve now got it working in the Metro theme. It would actually be very useful if you could set the column width in HA. In most languages the names are longer than in English. As far as I have seen, the HA team has had a corresponding suggestion for improvement since 2022.
Thanks for reporting this. It seems it was (partially) an issue on my end . I thought I had the hacs.json configuration file properly configured to search the dist directory in the repository, but HACS preferred the root global-mod.js. But that’s the source file and not the distributed file and thus won’t work.
I have just released 0.2.1 where I moved the dist to the root and the source to a new src directory which will resolve the issue.
Maybe a little TMI for you, but just want to be transparent what was going on .
Please update to the latest version (0.2.1) to see if that fixes it. Otherwise I recommend you try it with the default theme first. And please report if there any errors within the DevTools Console F12.
I had the latest version, tryed with the default one and worked.
I found the problem, it wasn’t recognizing the color: I hd to vrite the color like this: #fab387 and not like this: “#fab387”. without "
BTW, as someone that was not using themes nor had any idea about themes, I think it could be good to specify that user should create a directory named “themes” in base default home assistant directory if it is not already there. Took me a while to figure out.