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

Suggestion: improve support for color css variables #3953

Closed
germsb opened this issue Mar 23, 2021 · 2 comments · Fixed by #7665
Closed

Suggestion: improve support for color css variables #3953

germsb opened this issue Mar 23, 2021 · 2 comments · Fixed by #7665

Comments

@germsb
Copy link

germsb commented Mar 23, 2021

What version of @tailwindcss/jit are you using?

0.1.6

What version of Node.js are you using?

14

What browser are you using?

all

What operating system are you using?

linux

Reproduction repository

no need

Today with tailwind, it is not that easy to use the colors stored in a css variable.
If we do this --color-primary: theme(colors.blue.500);, --color-primary: #hexcolor;,
--color-primary: rgb (255,255,255) or other color format, we definitely lose the ability to add color opacity.

So, we are forced to store the color in an unconventional way: --color-primary: 59, 130, 246;.
This brings some disappointment: hand conversion, no visual on colors in IDEs

Imgur

I think it will be interesting to have a function available that allows at build time to convert the most common color format to one that takes advantage of opacity. Like that

Imgur

/* result to */
--color-primary: 59, 130, 246;
  • After that, in the same way, we can declare the color in tailwind.config
// ...
colors: {
                yellow: colors.orange,
                primary: varToRgba('--color-primary'),
}
// ...
  • And / or, as in a recent similar library, proposing to create classes on the fly with a syntax like this: border-$color-primary (with opacity support of course)

Thanks a lot for your work!

@adamwathan adamwathan transferred this issue from tailwindlabs/tailwindcss-jit Apr 5, 2021
@adamwathan adamwathan added the jit label Apr 5, 2021
@captenmasin
Copy link

Would love to see variables get first class support
Currently using https://github.com/mertasan/tailwindcss-variables which is great for generating and using variables, but overriding means writing css like colors-primary-rgb: 255, 0, 255;

@barrycenter
Copy link

If you're revisiting the color system, please make it work with CSS Color Level 4 (see: #2218) as well.

The way the colors are deconstructed internally makes it absolutely impossible to specify any color using the CSS color() function and have it work with opacity.

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.

5 participants