Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

fill-current is not defined if I overwrite theme color in tailwind

In tailwind, if I redefine the palette color, instead of extending it, the fill-current utilites is lost.

For example, I have the following code:

<p class="text-custom-red">
Hi
<svg
    class="fill-current"
    width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
>
    <path
        d="M12.0016 ..."
    />
</svg>
</p>

With the following config it works as expected (the svg icon is red)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

/** @type {import('tailwindcss').Config} */
module.exports = {
  theme: {
    extend: {
      colors: {
        'custom-red': '#fa364a',
      },
    },
  },
  plugins: [],
}

But if I overwrite the them color instead of extending it the fill-current utility is gone, and the icon is left black:

/** @type {import('tailwindcss').Config} */
module.exports = {
  theme: {
    colors: {
      'custom-red': '#fa364a',
    },
  },
  plugins: [],
}

note: check this tailwind playground

>Solution :

You need to add current as a custom color to your config.

module.exports = {
  theme: {
    colors: {
      'custom-red': '#fa364a',
      current: 'currentColor',
    },
  },
  plugins: [],
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading