I am using ubuntu 22.04 so this may be fine on windows/mac. When you preview a card containing an SVG in the browser (not clicking the preview button), if the card contains colour variables in a <style>
, they will not be rendered in the preview.
Here is an example svg to illustrate this problem:
<svg width="200" height="100" xmlns="http://www.w3.org/2000/svg">
<style>
:root {
--colour-1: yellow;
}
</style>
<rect width="200" height="100" fill="var(--colour-1)"></rect>
</svg>
When this is pasted inline into a card through the HTML editor, the browser preview always seems to be completely black. Specifically whatever element is coloured with a colour variable is always black:
Strangley this isn’t an issue when you press the preview button:
This also stops being an issue if you write the svg slightly differently like so:
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" style="--colour-1:yellow">
<rect width="200" height="100" fill="var(--colour-1)"></rect>
</svg>
This looks minor here, but for other svgs, it can lead to the user not being able to understand at all what is going on. For example, below is a svg compass which now looks reallly weird:
when it should look like this: