Tailwindcss: Color utilities for SVG fill

Created on 27 Nov 2017  路  2Comments  路  Source: tailwindlabs/tailwindcss

What are your thoughts on adding fill utilities for all of the set colors? For instance .fill-blue, .hover:fill-blue, etc.

I'm guessing it there would be file size implications but as an optional feature I would definitely use them.

Most helpful comment

Hey @James-ONeill! Right now the recommended way to handle this is using the text color utilities.

We provide a bit of code in our base styles for making this work:

svg { fill: currentColor; }

So if you use a class like text-red on an SVG element, it will set the fill to that text color.

I am thinking about adding separate scales for fill and stroke though for people who want more control, going to discuss it with the team and see what they think.

All 2 comments

Hey @James-ONeill! Right now the recommended way to handle this is using the text color utilities.

We provide a bit of code in our base styles for making this work:

svg { fill: currentColor; }

So if you use a class like text-red on an SVG element, it will set the fill to that text color.

I am thinking about adding separate scales for fill and stroke though for people who want more control, going to discuss it with the team and see what they think.

Thanks @adamwathan, I didn't notice that the text color utilities existed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

spyric picture spyric  路  3Comments

Quineone picture Quineone  路  3Comments

nternetinspired picture nternetinspired  路  3Comments

divdax picture divdax  路  3Comments

manniL picture manniL  路  3Comments