Skip to content

Conditional appearances for icons in the card depending on other entity state? #220

Answered by Nerwyn
gitgomie asked this question in Q&A
Discussion options

You must be logged in to vote

The Appearance CSS Styles codebox would be the correct area. You can include CSS with templates either here in the General tab or in the Elements tab with a custom element that overwrites/inherits from a default element.

Every field is templatable, so you can wrap these styles in templates to only apply on entity states. You can also reference the card config fields (or custom element individual config) using config in templates as shown below. This style in the general tab appearance CSS styles field would color the power button when the configured media player is on.

{% if is_state(config.media_player_id, "on") %}
#power::part(icon) {
  color: var(--red-color);
}
{% endif %}

See this se…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@gitgomie
Comment options

@Nerwyn
Comment options

@gitgomie
Comment options

Answer selected by gitgomie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants