brondum
(Brondum)
April 14, 2020, 6:23am
1
Hi Guys.
I have run into a small problem that i cant seem to get my head around.
I am trying to resize an icon within a markdown card.
original content:
- type: 'custom:hui-markdown-card'
content: >
<ha-icon icon="mdi:{{ states('sensor.weather_icon') }}"></ha-icon>
I have tried by adding style to the element, but it ignores when rendering.
- type: 'custom:hui-markdown-card'
content: >
<ha-icon icon="mdi:{{ states('sensor.weather_icon') }}" style="width: 45px;"></ha-icon>
Any ideas on how i can change this ?
1 Like
AhmadK
(akasma74)
April 14, 2020, 6:34am
2
open Inspector and check why it is âignoredâ.
for these things you have to see whatâs inside.
I can only say that
style:
font-size: 1.4vw
wonât work anyway it doesnât look like a proper CSS selector.
Iâd suggest to post your cardâs config here as just this bit might not be enough.
brondum
(Brondum)
April 14, 2020, 6:41am
3
The debugger in Chrome does not give me much, at least not in the console.
Only thing i can see is that my style
element from the <ha-icon>
is not rendered. It just gets ignored.
Tried adding an ID as well, same story.
AhmadK
(akasma74)
April 14, 2020, 6:46am
4
Inspector. Right click on your element â Inspect. Next pane to Console.
because card-mod canât find where to apply it.
start with
style:
.: '* {display: here}'
to get an idea where you are.
brondum
(Brondum)
April 14, 2020, 6:50am
5
Finding the element is not the issue
Actually i should have left out the style stuff from card-mod, because that is meant for the text not the icon. Just pasted in the top of the card.
AhmadK
(akasma74)
April 14, 2020, 1:35pm
6
add height: 45px;
to your style
petro
(Petro)
April 14, 2020, 5:21pm
7
The only way you can do it is with card mod. The following should work, but keep in mind, all icons will be this way size:
- type: markdown
style: |
ha-card {
--iron-icon-width: 45px;
--iron-icon-height: 45px;
}
content: >
<ha-icon icon="mdi:{{ states('sensor.weather_icon') }}"/>
brondum
(Brondum)
April 15, 2020, 5:12am
8
Thank you very much Petro.
Bummer, but then i will have to do some trickery with multiple cards or something.
Thanks
petro
(Petro)
April 15, 2020, 11:00am
9
For what itâs worth, if you just need an icon, you can use custom:button-card. Itâs much more manageable if youâre trying to piece meal a âcrazyâ interface.
1 Like
sorry to bump this, but itâs the only reference I can findâŚ
using:
card:
type: markdown
style: |
ha-card {
background: #103773;
color: white;
--iron-icon-width: 45px;
--iron-icon-height: 45px;
}
content: >
{% set alarm_color = state_attr('binary_sensor.meteoalarm_brabant','awareness_level').split(' ')[1].split(';')[0] %}
## <font color= {{alarm_color}}> {{state_attr('binary_sensor.meteoalarm_brabant','headline')}}</font>
<font color= {{alarm_color}}><ha-icon icon= {{states('sensor.meteoalarm_icon')}}></ha-icon></font>
<font color= {{alarm_color}}> **Severity:**</font> {{state_attr('binary_sensor.meteoalarm_brabant','severity')}}
<font color= {{alarm_color}}> **Type:**</font> {{state_attr('binary_sensor.meteoalarm_brabant', 'awareness_type').split(';')[0]}}
<font color= {{alarm_color}}> **Description:**</font>
{{state_attr('binary_sensor.meteoalarm_brabant','description')}}
<font color= {{alarm_color}}> [{{state_attr('binary_sensor.meteoalarm_brabant','attribution')}}]({{state_attr('binary_sensor.meteoalarm_brabant','web')}})</font>
or anything else I tried thus far doesnât affect the icon size:
the element is called âha-svg-iconâ which I have also tried to no avail unfortunately. Is this a lost cause, or should I try something elseâŚ
note I have set a font color to the icon to have it accept a color change, maybe I should try and style the in the ha-card styling too?
thanks for having a look
petro
(Petro)
February 1, 2021, 1:06pm
11
verify that the css names are still iron-icon-height and width. They may have changed.
youâre right: Iron icon height / width not working anymore
its now --mdc-icon-size
style: |
ha-card {
background: #103773;
color: white;
--mdc-icon-size: 50px;
}
10 Likes