Repository navigation
Add rgb and hsl color helpers for CSS variables - #7665
Merged
Merged
Conversation
idk what the formatting difference is… it won’t show me. :D
thecrypticace
force-pushed
the
feature/color-functions
branch
from
February 25, 2022 18:55
96978e5 to
0f1386e
Compare
This was referenced Feb 25, 2022
Contributor
|
This is an awesome addition. Would it be possible to add a second parameter to the RGB specifying the default opacity? This way it would allow us to define variables like this: Thanks! |
|
Hi, friend, I wanna use ...
colors: ({ rgb }) => ({
primary: rgb("var(--color-primary)"),
secondary: rgb("var(--color-secondary)"),
}),
...ooops, my |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds two new helpers that can be used to simplify using colors that are CSS variables. The colors MUST use the space separated syntax, and MUST NOT use an alpha channel in their value as Tailwind CSS adds that itself. The user can customize the alpha by using the opacity modifier syntax for colors (e.g. the
/50intext-primary/50).The
rgbandhslfunctions only expect the name of a CSS variable / custom property at present. We may revisit this in the future but this will give those who are using CSS variables a nicer, terse syntax for defining their config in a way that works with placeholders, borders, rings, etc…Closes #4659
Fixes #3953