Hi all
Somebody can tell me how to get number of lights turn on in JSTemplate to display in badge ?
I have the following YAML which working but donāt understand to get it OK in JSTemplate.
Maybe Iām dumb but is there a way to make the badges conditional? I want a badge with how many lights are on but it still returns a blank badge even with the sensor outputting null.
Actually, most custom cards in Home Assistant use JS templates, instead of yaml. When I first started navbar-card, I looked into how other custom cards handled templating and found that JS templates were the most standardized approach.
That being said, I completely agree it can be confusing, HA itself uses yaml templates, while most custom cards use Javascript. From a implementation standpoint though, JS templates are generally simpler to work with.
Iām still not 100% sure it was the perfect decision, and I might explore migrating to YAML templates in the future. The obvious downside will be, that it would break existing configurations for all current users, which is not desirable.
Right not the .label component does not have the .active class modifier (need to fix it for the next release). But you can do it targetting the .popup-item component:
.popup-item.active .label {
color: red !important;
}
You can use HA css variables for common colors, like --card-background-color for the cardās background, or --primary-text-color for text color. You can find lots of already pre-defined variables covering most use cases in the frontend repo of Home Assistant.
You could also manually define the styles with css media queries, targetting the dark mode:
Did you eventually fix this? If not, feel free to open a issue on github and Iāll investigate further
Yes! All of them can be done using the styles prop:
type: custom:navbar-card
...
desktop:
show_labels: true
mobile:
show_labels: true
styles: |
/* Display label only for active route */
.label:not(.active) {
display: none;
}
/* Increase the gap between routes */
.navbar-card {
gap: 50px !important;
}
/* Icon color only for active route */
.route.active .icon {
--icon-primary-color: red !important;
}
Though, for the active icon color, you might be looking for the selected_color prop of each route. You can find more info on the docs, and see one example configuration here
Hi @PedroKTFC , navbar-card is not designed to be used inside other layouts (like vertical layout card) but Iāll try to give you some solutions:
1. Sizing
You can try disabling the absolute positioning of the card, but keep in mind, this might break things (specially if you are using the media_player widget of navbar-card)
Apart from this card not being designed to work inside other layouts, Iāve also neglected adapting it to the position: top variant So bugs like this are likely to happen. Iāll try fixing it for future releases but, two things:
This issue will be fixed when using the suggestion from the first section. When changing the position to relative, there will be no overlap with the header section
You can completely hide the native HA header, and use navbar-card custom actions to toggle the side menu, open edit mode, launch assist⦠etc. Just take a look at the supported actions and that might make you change your mind over using navbar-card as it is, instead of relying on the relative positioning
Is there an option to make the pop-up appear at the bottom instead of at the top?
And another option to use images instead of icons?
Thanks for your help!
Hey,
i want to display a route only if a sensor is āonā from a list of sensors, so i tought it should work with the hidden option. This i my js code but it doesnĀ“t work. Can someone help?