SVG-Export: add feature to export local variable names into svg code with static-color fallback

When working with SVG assets within a design system we’re often using named color variables that are part of the design system so that our designs support different color modes (light, dark etc)

it would be super helpful if there was some way for these variables made their way into the SVG code (with a fallback for situations or usages where the variable may not exist)

So in your SVG export instead of this:

<rect x="0.331604" y="0.717941" width="20.9977" height="20.9977" fill="#ffffff"/>

you’d get something like this

<rect x="0.331604" y="0.717941" width="20.9977" height="20.9977" fill="var(--color-background, #ffffff)"/>

which would then be able to be able to be dynamically changed based on what is being set for --color-background in the consuming web app.

9 Likes

would also be great to be able to strip out any fill opacity values from the svg when using color variables as the fill (as opacity is often already set within the variable)

Hey Tim! Thanks for your feedback on SVH-export! I’ve gone ahead and switched your topic as “Share an idea”.

This would be great.

I would add to have this option in the REST api GET images endpoint too.

1 Like

I agree!! We need this so badly. We have to use hacks today and switch the color by one bit to identify different semantic colors so that we can handle them correctly in the code. Please add this feature!!

3 Likes

Good suggestion I’d love to see this.

Need this!!!
Could we do this in an optimized way, somehow?
Is there any plugin that could help me do this…?