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

Tokens do not support tw-opacity #2096

Closed
PrisionMikeLime opened this issue Oct 1, 2023 · 2 comments
Closed

Tokens do not support tw-opacity #2096

PrisionMikeLime opened this issue Oct 1, 2023 · 2 comments
Labels
feature request Request a feature or introduce and update to the project. wontfix This will not be worked on

Comments

@PrisionMikeLime
Copy link

Current Behavior

When using bg-primary-50-900-token for example the code generated is:

.dark .bg-primary-50-900-token {
    background-color: rgb(var(--color-primary-900));
}
.bg-primary-50-900-token {
    background-color: rgb(var(--color-primary-50));
}
.dark .bg-primary-50-900-token {
    background-color: rgb(var(--color-primary-900));
}

So using tailwind opacity has no effect.

Expected Behavior

Generated code should support tw opacity

.dark .bg-primary-50-900-token {
    background-color: rgb(var(--color-primary-900) / var(--tw-text-opacity));
}
.bg-primary-50-900-token {
    background-color: rgb(var(--color-primary-50) / var(--tw-text-opacity));
}
.dark .bg-primary-50-900-token {
    background-color: rgb(var(--color-primary-900) / var(--tw-text-opacity));
}

Steps To Reproduce

Simply use tailwind's opacity feature with a bg with token: class=`bg-primary-50-900-token bg-opacity-60` .

Link to Reproduction / Stackblitz

No response

More Information

I believe other uses of color might need to support transparency too.

@PrisionMikeLime PrisionMikeLime added the bug Something isn't working label Oct 1, 2023
@endigo9740 endigo9740 added feature request Request a feature or introduce and update to the project. and removed bug Something isn't working labels Oct 2, 2023
@endigo9740
Copy link
Contributor

@PrisionMikeLime this sounds interesting, but I'd have to test to ensure this works in this manner.

I've also relabeled this as a feature as the current implementation is working as expected. This behavior is not a bug, but rather a new feature request.

@endigo9740
Copy link
Contributor

endigo9740 commented Dec 19, 2023

@PrisionMikeLime after reviewing this, unfortunately Tailwind does not seem to provide a way to pass down opacity from a custom utility class as you described. See my reproduction here:

https://play.tailwindcss.com/ih7AFNWnws

Check the HTML/CSS tabs to see this in practice.

I'd recommend that if you need this approach, you break out the individual classes and apply opacity directly to those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request a feature or introduce and update to the project. wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants