Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theme() with css variable colors doesn't work in .css files #8643

Closed
maxsalven opened this issue Jun 15, 2022 · 1 comment · Fixed by #8652
Closed

theme() with css variable colors doesn't work in .css files #8643

maxsalven opened this issue Jun 15, 2022 · 1 comment · Fixed by #8652
Assignees

Comments

@maxsalven
Copy link

maxsalven commented Jun 15, 2022

What version of Tailwind CSS are you using?

v3.1.3

What build tool (or framework if it abstracts the build tool) are you using?

postcss 8.4.14

What version of Node.js are you using?

v16.13.1

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction URL

https://play.tailwindcss.com/eoS0xJO1cm

Describe your issue

If you use css variable for colors, then theme doesn't work in .css files:

module.exports = {
  theme: {
    colors: {
      blue: 'rgb(var(--blue) / <alpha-value>)',
    },
  },
  plugins: [],
}
@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  --blue: 0 0 255;
}

.custom-class {
  color: theme("colors.blue");
}

Generated css:

.custom-class {
    color: rgb(var(--blue) / <alpha-value>);
}
@thecrypticace
Copy link
Contributor

Hey! Appreciate the report on this one — I've merged the fix and it'll be in our next release. Will likely tag one in the morning (Eastern US Time). The problem here was that when we didn't see an alpha we didn't try replacing the <alpha-value> placeholder. In the short term you can work around this by doing theme(colors.blue / 1) or by using our insiders build: npm install tailwindcss@insiders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants