You should only need to put it once, outside of modes.
You can create a theme that doesnāt change anything but adds card-mod.
It sounds like thereās a problem with your code.
It tells card-mod what to do, and it lets you create separate themes with styles you can tack on to another one.
You can create a variable, even if it isnāt included in HA. Then you could reference it like margin: var(--margin-in-dark-mode) in card-mod if you set it up like margin-in-dark-mode: 20px in your theme.
Suppose these ācard-mod-view-yamlā-like sections (which defining styles, I think) are placed below that ācard-mod-theme: noctisā line.
All this code is placed inside some theme (but outside modes) - I guess that this code already belongs to this particular theme, it is strange for me that we need to specify a name again.
Also, if some theme is called ātheme123ā - should that ānameā line be "card-mod-theme: theme123" (i.e. same name)? And if the theme is called āCustom Themeā? Update: seems that this line must be exactly the same as the themeās name (i.e. "card-mod-theme: "Custom Theme"" )
Yes, I call them āuser-defined variablesā.
So, if I understood your post properly, I got this code:
My 1st small victory! (have no idea why it did not work earlierā¦)
Anyway, do not understand the meaning of that "card-mod-theme: "Custom Theme"" - since it repeats the name of the theme.
No no no, it was not working first ))) I have no idea why!
Oh, that was a real starting point, thank you.
Actually, I was not going to dig into card-mod-themes right NOW - I planned to start learning it a bit later.
But I needed to set a fixed width to the right sidebar - so I started thinking about card-mod-themes.
Update 06.12.24: the code used to have a āwidth: -webkit-fill-available;ā line - but now I do not see it needed. Let me know if the code does not work as expected.
OMG, one more excited post:
just yesterday started learning this mod - now I think card-mod-themes is one of greatest fundamental features in HA frontend like decluttering-card.
Thank you, @thomasloven !
All I want to do is add a clock to the header. This was easy with CCH but for some reason Iām having trouble using Card-mod. I added this to the end of my theme (Github Dark Theme)
I guess that code is now outdated since HA changed a structure of a page.
Try the code below.
I changed a DOM path (did not touch height, width & position).
trying to change the icon of a tab is about the only thing left I like to establish in replacing my Custom Header from the old days. Please help me figuring this out.
We can change the color of a tab with:
paper-tab[aria-label='Home'] {
color: {{'red' if states('sensor.count_alerts_notifying') > '0'}};
}
but adding an icon line there wont work, inspector says the icon is inherited from ha-tabs, and shows a yellow exclamation mark.
If I try and do something like:
/* Set the color of the currently selected tab indicator. */
ha-tabs {
--paper-tabs-selection-bar-color: black !important;
--paper-tab[aria-label='Home summary'] {
ha-icon: mdi:help !important;
};
}
nothing happens, except for the tab indicator being colored black.
which overrides a background set in the regular View:
title: Solar
path: solar
icon: mdi:solar-power
background: center / cover no-repeat url('/local/images/solar_grid.png') fixed
maybe we can also override the icon like that?
answering myself: no we cantā¦ there simpāy doesnt seem to be an item to override (set a value for in card-mod-theme) for icon?
Background may be changed by a corresponding property.
Icon may be changed by a brute force method:
card-mod-root-yaml: |
paper-tab[aria-label='zont'] ha-icon $ ha-svg-icon $: |
path {
{% if is_state('input_boolean.test_boolean','on') %}
d: path("M 20.2 5.9 L 21 5.1 C 19.6 3.7 17.8 3 16 3 C 14.2 3 12.4 3.7 11 5.1 L 11.8 5.9 C 13 4.8 14.5 4.2 16 4.2 C 17.5 4.2 19 4.8 20.2 5.9 M 19.3 6.7 C 18.4 5.8 17.2 5.3 16 5.3 C 14.8 5.3 13.6 5.8 12.7 6.7 L 13.5 7.5 C 14.2 6.8 15.1 6.5 16 6.5 C 16.9 6.5 17.8 6.8 18.5 7.5 L 19.3 6.7 M 19 13 H 17 V 9 H 15 V 13 H 5 A 2 2 0 0 0 3 15 V 19 A 2 2 0 0 0 5 21 H 19 A 2 2 0 0 0 21 19 V 15 A 2 2 0 0 0 19 13 M 8 18 H 6 V 16 H 8 V 18 M 11.5 18 H 9.5 V 16 H 11.5 V 18 M 15 18 H 13 V 16 H 15 V 18 Z") !important;
color: magenta !important;
{% else %}
d: path("M 12 2 A 10 10 0 0 0 2 12 A 10 10 0 0 0 12 22 A 10 10 0 0 0 22 12 A 10 10 0 0 0 12 2 M 16.2 16.2 L 11 13 V 7 H 12.5 V 12.2 L 17 14.9 L 16.2 16.2 Z") !important;
color: cyan !important;
{% endif %}
}