Compare these cards:
type: vertical-stack
cards:
- type: picture-glance
image: /local/images/test/blue.jpg
title: +
entities: &ref_entities
- entity: sensor.processor_use
show_state: true
- entity: sensor.processor_use
show_state: true
- entity: sensor.processor_use
card_mod:
style:
.box div:nth-child(2):
div:nth-child(1):
ha-icon-button ha-state-icon:
$: |
ha-icon {
color: red;
}
div:nth-child(2):
ha-icon-button ha-state-icon:
$: |
ha-icon {
color: orange;
}
div:nth-child(3):
ha-icon-button ha-state-icon:
$: |
ha-icon {
color: yellow;
}
- type: picture-glance
image: /local/images/test/blue.jpg
entities: *ref_entities
card_mod:
style:
.box div:nth-child(1):
div:nth-child(1):
ha-icon-button ha-state-icon:
$: |
ha-icon {
color: red;
}
div:nth-child(2):
ha-icon-button ha-state-icon:
$: |
ha-icon {
color: orange;
}
div:nth-child(3):
ha-icon-button ha-state-icon:
$: |
ha-icon {
color: yellow;
}
As I said here - indexing should be corrected when a title is added/removed.
tknice
December 21, 2022, 5:15pm
4088
I get it now, changed the .box div:nth-child(2) to a (1). thanks.
stepsolar
(Stepsolar)
December 21, 2022, 11:04pm
4089
How could I insert an svg file with the possibility of being able to modify its CSS?
arganto
December 23, 2022, 10:07am
4091
Why not? Search for a kind of mapping table or mapping formular from kelvin to rgb (look-a-like) and then set it accordingly with a fitting template.
Btw, using an HSL format for a color I consider as the best choice for a temperature - if talking about kettles, boilers etc - i.e. related to heating.
Could somebody help me. I want in a vertical-stack card disappear this area between the two stacks:
How I do that?
Abeksis
December 24, 2022, 7:47am
4095
Allow help please?
I want this caption including the subconscious to right (RTL). I would love for help please
I tried to add this code:
card_mod:
style: |
ha-card {
direction: rtl;
}
But everything goes right - and there is no profit between the icon and the text
type: custom:stack-in-card
cards:
- type: custom:mushroom-template-card
entity: sensor.dishwasher_cost_curr_month
primary: ×××× ×××× - ×Ŗש××× ×××ש×
secondary: |
{{ states('sensor.dishwasher_cost_curr_month') }} āŖ
icon: mdi:dishwasher
icon_color: orange
tap_action:
action: more-info
Removing internal borders & margins inside vertical-stack
:
Default:
type: vertical-stack
cards:
- type: entities
entities:
- sun.sun
- type: entities
entities:
- sun.sun
Styled:
type: custom:mod-card
card_mod:
style:
hui-vertical-stack-card $: |
div#root hui-card > * {
--ha-card-border-width: 0px;
}
.: |
hui-vertical-stack-card {
--vertical-stack-card-gap: 0px;
}
ha-card {
box-shadow: var(--ha-card-box-shadow);
border: var(--ha-card-border-color,var(--divider-color,#e0e0e0)) solid var(--ha-card-border-width,1px);
background: var(--ha-card-background,var(--card-background-color,#fff));
}
card:
type: vertical-stack
cards:
- type: entities
entities:
- sun.sun
- type: entities
entities:
- sun.sun
1 Like
ido_1
December 24, 2022, 6:26pm
4097
Hi, can anyone help me with this:
type: horizontal-stack
cards:
- type: custom:vertical-stack-in-card
card-mod:
style: ''
cards:
- type: button
hold_action:
action: none
icon: mdi:volume-plus
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: VOLUMEUP
entity_id: media_player.tv
- type: button
hold_action:
action: none
icon: mdi:volume-minus
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: VOLUMEDOWN
entity_id: media_player.tv
- type: custom:vertical-stack-in-card
style: |
ha-card {
aspect-ratio: 1/1;
border-radius: 50%;
}
cards:
- type: horizontal-stack
cards:
- type: custom:button-card
color_type: blank-card
- type: button
hold_action:
action: none
icon: mdi:menu-up-outline
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: UP
entity_id: media_player.tv
- type: custom:button-card
color_type: blank-card
- type: horizontal-stack
cards:
- type: button
hold_action:
action: none
icon: mdi:menu-left-outline
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: LEFT
entity_id: media_player.tv
- type: button
hold_action:
action: none
icon: mdi:circle-outline
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: ENTER
entity_id: media_player.tv
- type: button
hold_action:
action: none
icon: mdi:menu-right-outline
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: RIGHT
entity_id: media_player.tv
- type: horizontal-stack
cards:
- type: custom:button-card
color_type: blank-card
- type: button
hold_action:
action: none
icon: mdi:menu-down-outline
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: BOTTOM
entity_id: media_player.tv
- type: custom:button-card
color_type: blank-card
- type: custom:vertical-stack-in-card
style: ''
cards:
- type: button
hold_action:
action: none
icon: mdi:arrow-up-circle-outline
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: CHANNELUP
entity_id: media_player.tv
- type: button
hold_action:
action: none
icon: mdi:arrow-down-circle-outline
show_icon: true
show_name: false
tap_action:
action: call-service
service: webostv.button
service_data:
button: CHANNELDOWN
entity_id: media_player.tv
Iāve tried all sort of css codes to make the cards 20% 60% 20% centered both horizontally and vertically and make the icons in the middle a bit bigger but couldnāt manage to fix it
WoJWoJ
December 25, 2022, 9:02pm
4098
As kindly suggested by @Ildar_Gabdullin I am reposting my question in this thread
I am trying to use mod-card
in order to style a button-card
(this is an example, there are other cards as well)
This is the element I want to style (the text ādate hereā):
Its position in the DOM is
My understanding is that I have, starting from <button-card>
, the following structure:
(it does not matter until <ha-card>
)
<ha-card>
with a shadow-root, so I need to address it as ha-card$
a <div>
another nested <div>
that contains the text I want to style
The code I imagined would work:
- type: custom:button-card
name: >
[[[
return "date here"
]]]
view_layout:
grid-area: date
card_mod:
style:
ha-card$:
div: |
div {
font-size: 100px;
color: red;
}
Well, it does not , the style is not applied. Is this how I am expected to code nested elements?
Note: a basic
card_mod:
style: |
ha-card {
color: red;
}
works fine, so mod-card
is correctly installed.
No, starting from an upper level.
Check this:
type: custom:mod-card
card:
type: custom:button-card
entity: sun.sun
card_mod:
style:
button-card $: |
div#container div#name {
color: red;
}
This is a common way, but:
No need to use the āmod-cardā for the ābutton-cardā since the ābutton-cardā already has a āha-cardā element.
The ābutton-cardā has itās own possibilities to style elements (could be enough in some cases).
1 Like
u20p17
(Franz)
December 26, 2022, 11:06am
4100
Hi all,
I am working on a picture-element card in HA where the whole heating system of the house should be displayed. I finished with this on my laptop and everything looks good in full screen. Here an example:
Nevertheless, if I rescale the window size, the size of the state-badge stay the same ā they become to bigā¦ How can I archive it that they also get defined their sizes in % of the window size?
I believe that this should be possible with card-mod, am I right?
My config up to now looks the following:
type: picture-elements
elements:
- type: state-badge
entity: sensor.node_1_input_1
style:
top: 15%
left: 11%
transform: translate(-50%,-50%) scale(0.7,0.7)
- type: state-icon
entity: binary_sensor.pumpe_solar_state
style:
top: 39.5%
left: 26.5%
transform: translate(-50%,-50%) scale(0.7,0.7)
image: /local/pictures/HeizungsĆ¼berblick.jpg
u20p17
(Franz)
December 26, 2022, 12:00pm
4102
Thanks for your fast answer
Note that on a smaller viewport elements become BIGGER (respectively to the main image).
This may be solved by scaling elements differently on different viewports ("transform: translate(-50%,-50%) scale(diff_scale_value,diff_scale_value)").
Two ways may be used:
ā the whole floorplan card is a decluttering-card - pass a scale value as a variable;
ā use card-mod to set scales conditionally dependingly on a current viewport (use āmediaqueryā).
I already saw this but I couldnāt figure out what I have to do in order to solve my problemā¦ How can I read out the window width and height in order to change the diff_scale_value accordingly?
e-raser
December 26, 2022, 5:19pm
4104
How can I combine this (styling the entity icon)
style:
hui-generic-entity-row:
$: |
state-badge {
{% if states('sensor.watchman_missing_entities') | int(0) > 0 %}
color: orange;
{% endif %}
}
with this (styling the entity value):
style: |
.state.entity {
{% if states('sensor.watchman_missing_entities') | int(0) > 0 %}
color: cyan;
{% endif %}
}
for one custom:multiple-entity-row
type?
I donāt know how to syntactically mix both so one style:
definition applies them all.
e-raser
December 26, 2022, 5:49pm
4105
How to set the margin-top
and margin-bottom
for a custom:fold-entity-row
?
It uses too much space, example:
This is not working unfortunately:
- type: custom:fold-entity-row
head:
type: section
label: Watchman Report
style: |
.divider {
background-color: transparent !important;
#margin-top: -15px !important;
}
padding: 0
open: false
entities:
- ...
card_mod:
style:
.: |
ha-card {
margin-top: -15px; # <-- not working
margin-bottom: -15px; # <-- not working
}
arganto
December 26, 2022, 6:13pm
4106
Always think first, that most probably a lot of users such questions before and go through some example from Ildar or in this thread. And you will directly see the answers.
e.g. above here
e-raser
December 26, 2022, 6:40pm
4107
Unfortunately itās not that easy. I tried all possible combinations. The referenced example unfortunately is not helpful in this context.
hui-generic-entity-row:
must not have a pipe (|
) in the style: |
line before, while .state.entity {
does. So how do you combine those.
Update:
found the solution.
style:
.: |
.state.entity {
{% if states('sensor.watchman_missing_entities') | int(0) > 0 %}
color: cyan;
{% endif %}
}
hui-generic-entity-row:
$: |
state-badge {
{% if states('sensor.watchman_missing_entities') | int(0) > 0 %}
color: orange;
{% endif %}
}
Donāt understand it (cause this DOM navigation stuff is just complicated as f*** ) but itās working.