Adding Custom CSS properties for ha-card


#1

Hey guys,

I would like to theme the UI a bit more than currently possible. That’s quite hard to do, because HA uses web components which are encapsulated and can’t be styled from the outside (anymore). I currently use a hacky JS solution but I’d rather like to add a few CSS variables to the mix:

–paper-card-border-radius
–paper-card-margin
–paper-card-border-width
–paper-card-border-color
–paper-card-border-style

Do I need to do anything more than open a PR for ha-style.js and ha-card.js and add the properties?


#2

If you are using lovelace, use the custom card:modder


#3

Unfortunatly, (as far as I understand) this forces you set a style for every single card separately - that’s exactly the kind of thing I want to avoid because It creates a terrifying mess in your config file.
My proposal would just extend the styling possibilities that are already there and would therefore well integrate with the existing theme engine.


#4

Hi there!

I’m using the hacky JS myself (which doesn’t work well on the mobile app) and am so frustrated with the lovelace theming. I’d see many more CSS variables to get better styling options.

Please let us know if your PR are merged and if you find any better solution!
Thanks :slight_smile:


#5

You should take a look here.


#6

Well, I’m considering forking the home-assistant-polymer repo to add more design flexibility. Let me know if you ever do it first or I’ll post my updates here.


#7

Been thinking about this but I’m quite unsure if it’s worth the work. Currently I use a JS script to inject the custom properties so that I can use the integrated theming functionality. If I find I way to listen to dom changes (there is MutationObserver but it can’t be used with nested shadow dom without attaching it to every shadowRoot) this could be a viable solution.

What kind of mobile app are you referring to?


#8

Hi! I’m using the homeassistant app, which is really cool. I also use a script to inject JS, but from time to time my theme is broken (when the app was open in background, most of the time)

If you find any clean way to make these changes with JS, please let me know, and I’ll try the fork solution. I just plan to make some css variable and property changes, so updating from time to time to the officiel version shouldn’t be so hard.


#9

How does one inject the lovelace-card-modder?