The Mushroom theme settings allow you to customize/override the the default settings of the Mushroom cards. For instance if you want to use amber for the lights, instead of orange, you can override it by adding mush-rgb-state-light: var(--mush-rgb-amber)
to your theme file. In the same way you can change what red is by specifying a different value for mush-rgb-red
, say pure red with mush-rgb-red: 255, 0, 0
. Now every time a Mushroom card uses red it will be this new value of red we have specified in our theme. These ‘mush’ values are only for Mushroom cards, they don’t affect any of the normal HA cards. The advantage of specifying the ‘mush’ values in a theme, even if we do not change them, is that they are now available to be used in CSS anywhere.
This is what I have in my Mushroom theme file:
mushroom-custom.yaml
Mushroom Custom:
# HA variables
ha-card-box-shadow: 0px 2px 4px 0px rgba(0,0,0,0.16)
ha-card-border-radius: 20px
# Mushroom layout
#mush-spacing: 12px
# Title
#mush-title-padding: 24px 12px 16px
#mush-title-spacing: 12px
#mush-title-font-size: 24px
#mush-title-font-weight: normal
#mush-title-line-height: 1.2
# Subtitle
#mush-subtitle-font-size: 16px
#mush-subtitle-font-weight: normal
#mush-subtitle-line-height: 1.2
# Card
#mush-card-primary-font-size: 14px
#mush-card-secondary-font-size: 12px
#mush-card-primary-font-weight: bold
#mush-card-secondary-font-weight: bolder
#mush-card-primary-line-height: 1.5
#mush-card-secondary-line-height: 1.5
# Chip
#mush-chip-spacing: 8px
#mush-chip-padding: 0 0.25em
#mush-chip-height: 36px
#mush-chip-border-radius: 18px
#mush-chip-font-size: 0.3em
#mush-chip-font-weight: bold
#mush-chip-icon-size: 0.5em
#mush-chip-avatar-padding: 0.1em
#mush-chip-avatar-border-radius: 50%
#mush-chip-box-shadow: var(--ha-card-box-shadow)
#mush-chip-background: var(--ha-card-background)
# Control
#mush-control-border-radius: 12px
#mush-control-height: 42px
#mush-control-button-ratio: 1
#mush-control-icon-size: 0.5em
# Slider
#mush-slider-threshold: 10
# Badge
#mush-badge-size: 16px
mush-badge-icon-size: 0.8em
#mush-badge-border-radius: 50%
# Icon
#mush-icon-border-radius: 50%
#mush-icon-size: 42px
#mush-icon-symbol-size: 0.5em
# Colors
mush-rgb-red: 244, 67, 54
mush-rgb-pink: 233, 30, 99
mush-rgb-purple: 156, 39, 176
mush-rgb-deep-purple: 103, 58, 183
mush-rgb-indigo: 63, 81, 181
mush-rgb-blue: 33, 150, 243
mush-rgb-light-blue: 3, 169, 244
mush-rgb-cyan: 0, 188, 212
mush-rgb-teal: 0, 150, 136
mush-rgb-green: 76, 175, 80
mush-rgb-light-green: 139, 195, 74
mush-rgb-lime: 205, 220, 57
mush-rgb-yellow: 255, 235, 59
mush-rgb-amber: 255, 193, 7
mush-rgb-orange: 255, 152, 0
mush-rgb-deep-orange: 255, 87, 34
mush-rgb-brown: 121, 85, 72
mush-rgb-grey: 158, 158, 158
mush-rgb-blue-grey: 96, 125, 139
mush-rgb-black: 0, 0, 0
mush-rgb-white: 255, 255, 255
#mush-rgb-info: var(--mush-rgb-blue)
#mush-rgb-success: var(--mush-rgb-green)
#mush-rgb-warning: var(--mush-rgb-orange)
#mush-rgb-danger: var(--mush-rgb-red)
#mush-rgb-state-fan: var(--mush-rgb-green)
mush-rgb-state-light: var(--mush-rgb-amber)
#mush-rgb-state-entity: var(--mush-rgb-blue)
#mush-rgb-state-switch: var(--mush-rgb-blue)
#mush-rgb-state-alarm-disarmed: var(--mush-rgb-info)
#mush-rgb-state-alarm-armed: var(--mush-rgb-success)
#mush-rgb-state-alarm-triggered: var(--mush-rgb-danger)
#mush-rgb-state-person-home: var(--mush-rgb-success)
#mush-rgb-state-person-not-home: var(--mush-rgb-danger)
#mush-rgb-state-person-zone: var(--mush-rgb-info)
#mush-rgb-state-person-unknown: var(--mush-rgb-grey)
#mush-rgb-state-cover-open: var(--mush-rgb-blue)
#mush-rgb-state-cover-closed: var(--mush-rgb-disabled)
#mush-rgb-state-climate-auto: var(--mush-rgb-green);
#mush-rgb-state-climate-cool: var(--mush-rgb-blue);
#mush-rgb-state-climate-dry: var(--mush-rgb-orange);
#mush-rgb-state-climate-fan-only: var(--mush-rgb-blue-grey);
#mush-rgb-state-climate-heat: var(--mush-rgb-deep-orange);
#mush-rgb-state-climate-heat-cool: var(--mush-rgb-green);
#mush-rgb-state-climate-idle: var(--mush-rgb-grey);
#mush-rgb-state-climate-off: var(--mush-rgb-disabled);
# You must keep this to support light/dark theme
modes:
light:
mush-rgb-disabled: 189, 189, 189
dark:
mush-rgb-disabled: 111, 111, 111
As you can see, most of it is commented out. I mainly use it for the mush-rgb-[color]
values.
To apply this to my Room card we can now do this:
type: custom:stack-in-card
cards:
- type: custom:mushroom-template-card
primary: Lounge
secondary: '{{ states("sensor.lounge_sensor_temperature") | round(0) }} °C'
icon: mdi:sofa
entity: light.lounge_light
tap_action:
action: navigate
navigation_path: lounge
hold_action:
action: toggle
icon_color: '{{ ''red'' if is_state(entity, ''on'') else ''disabled'' }}'
fill_container: true
layout: horizontal
multiline_secondary: false
card_mod:
style: |
:host([dark-mode]) {
background: rgba(var(--rgb-primary-background-color), 0.2);
}
:host {
background: rgba(var(--rgb-primary-text-color), 0.025);
--mush-icon-size: 76px;
height: 66px;
margin-left: -18px !important;
}
- type: custom:mushroom-chips-card
chips:
- type: conditional
conditions:
- entity: binary_sensor.lounge_motion_occupancy
state: 'on'
chip:
type: template
icon_color: disabled
icon: mdi:motion-sensor
tap_action:
action: none
hold_action:
action: none
- type: conditional
conditions:
- entity: media_player.lounge_tv
state_not: 'off'
- entity: media_player.lounge_tv
state_not: unavailable
chip:
type: template
icon_color: disabled
icon: |-
{% set media_type = state_attr('media_player.lounge_tv',
'media_content_type') %}
{% if media_type == 'tvshow' %}
mdi:television-classic
{% elif media_type == 'movie' %}
mdi:movie-open
{% elif media_type == 'music' %}
mdi:music
{% elif media_type == 'playlist' %}
mdi:music
{% else %}
mdi:plex
{% endif %}
tap_action:
action: none
hold_action:
action: none
- type: conditional
conditions:
- entity: climate.air_conditioner
state_not: 'off'
chip:
type: template
entity: climate.air_conditioner
icon_color: disabled
icon: |-
{% if is_state(entity, 'heat_cool') %}
mdi:sync
{% elif is_state(entity, 'heat') %}
mdi:fire
{% elif is_state(entity, 'cool') %}
mdi:snowflake
{% elif is_state(entity, 'dry') %}
mdi:water-percent
{% elif is_state(entity, 'fan_only') %}
mdi:fan
{% else %}
mdi:air-conditioner
{% endif %}
tap_action:
action: none
hold_action:
action: none
card_mod:
style: |
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
ha-card {
{% if is_state('climate.air_conditioner', 'fan_only') %}
animation: rotation 2s linear infinite;
{% endif %}
}
- type: conditional
conditions:
- entity: group.lounge_windows
state: 'on'
chip:
type: template
icon_color: disabled
icon: mdi:window-open
tap_action:
action: none
hold_action:
action: none
alignment: end
card_mod:
style: |
ha-card {
--chip-box-shadow: none;
--chip-background: none;
--chip-spacing: 0;
}
card_mod:
style: |
ha-card {
height: 102px;
{% if is_state('light.lounge_light', 'on') %}
background: rgba(var(--mush-rgb-red), 0.1);
{% endif %}
}
The last card_mod: style:
is being applied to the stack-in-card
, which is not a Mushroom card so cannot see the dynamically created --rgb-[color]
values. However it can see the --mush-rgb-[color] values that we have defined in our theme file.
Alternatively we can find the value of --rgb-orange
and manually specify that in our CSS, which is what I originally did with my Room card:
card_mod:
style: |
ha-card {
height: 102px;
{% if is_state('light.lounge_light', 'on') %}
background: rgba(255, 152, 0, 0.1);
{% endif %}
}
I hope that’s clearer than mud .