lovelace-card-mod: Custom font styling is not applied to markdown card
My Home Assistant version: 0.111.0
My lovelace configuration method (GUI or yaml): yaml
What I am doing: applying custom styling to a markdown-card
What I expected to happen: font styling is applied to element h1
What happened instead: no styling is applied. Safari reports User Agent Style Sheet
. Issue is present in Firefox too.
Minimal steps to reproduce: Use the aforementioned yaml in a view.
- type: markdown
content: |
# Vacuum automation
style: |
ha-card {
height: 50px;
--paper-card-background-color: 'rgba(11, 11, 11, 0.00)';
box-shadow: 2px 2px rgba(0,0,0,0.0);
}
h1 {
font-size: 14px;
font-weight: thin;
font-family: Helvetica;
letter-spacing: '-0.01em';
}
Error messages from the browser console: (I don’t think these are related)
[Error] hui-thermostat-card – Error: Specify an entity from within the climate domain.
Error: Specify an entity from within the climate domain.
s (chunk.6dbb65acb727c33dd251.js:2144:318438)
value (chunk.ab96942901cd9a8d7754.js:146:46870)
(anonymous function) (chunk.ab96942901cd9a8d7754.js:146:47612)
asyncFunctionResume
(anonymous function)
promiseReactionJobWithoutPromise
promiseReactionJob
[Error] hui-alarm-panel-card – Error: Invalid card configuration
Error: Invalid card configuration
s (chunk.6dbb65acb727c33dd251.js:2144:318438)
value (chunk.ab96942901cd9a8d7754.js:146:46870)
(anonymous function) (chunk.ab96942901cd9a8d7754.js:146:47612)
asyncFunctionResume
(anonymous function)
promiseReactionJobWithoutPromise
promiseReactionJob
[Error] Failed to load resource: the server responded with a status of 404 () (index.m.js.map, line 0)
By putting an X in the boxes ([ ]) below, I indicate that I:
-
Understand that this is a channel for reporting bugs, not a support forum (https://community.home-assistant.io/).
-
Have made sure I am using the latest version of the plugin.
-
Have followed the troubleshooting steps of the “Common Problems” section of https://github.com/thomasloven/hass-config/wiki/Lovelace-Plugins.
-
Understand that leaving one or more boxes unticked or failure to follow the template above may increase the time required to handle my bug-report, or cause it to be closed without further action.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 32 (4 by maintainers)
@ASNNetworks
I think it would be like this:
The markdown card now has the following structure
ha-card |__ shadow-root |__ha-markdown |__shadow-root |__ha-markdown-element
So, you need to follow the advanced usage instructions and do something like:
That appears to work and gives me:
Because it makes Home Assistant and it’s core functionality work better and more pretty. You can’t expect the core to accommodate for dirty hacks like card-mod.
The problem with h2 can be solved by using a more specific selector than the built in one, such as
@gadgetchnnel has the correct solution here.
Yeah, I found the offending code here:
https://github.com/home-assistant/frontend/blob/9ff2eece3aafe6e7ba26075aed2f981e12dbee1a/src/components/ha-markdown.ts#L72-L75
I’ve added that info to the (closed) issue I had created, asking Bram to review if this is as intended.
https://github.com/home-assistant/frontend/issues/6147
Works great - except for H2 headers? Seems there is some fixed styling somewhere that doesn’t get overridden.
I change the exact same lines to H1 (and #) and then it works, but styling h2 and using ## doesn’t work.
Non working code:
Change the ## to # and h2 to h1 to get a working styling.
Thanks Thomas, much appreciated.
Looks great, but in the end is more a workaround than it is the solution 😃
Done and pretty happy with the result.
You can style markdown by applying styles to
ha-card
. That’s what I did to solve this issue.Same issue on 0.111.0, rollback to 0.110.* fixes it immediately. As I’ve got a feeling it is HA frontend related, I’ve created an issue there.