[v4] How to support arbitrary CSS variables in custom utilties? #18792
-
|
Is there a way to support the (--my-variable) arbitrary syntax when creating you're own custom utilities to allow CSS variables?
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Yep! Use the wildcard @utility my-utility-* {
property: --value([*]);
}Otherwise, if you only want to allow a specific type, you can do so, but your class names would need to have the hint too: @utility my-utility-* {
property: --value([length]);
}<div class="my-utility-(length:--css-variable)"> |
Beta Was this translation helpful? Give feedback.
-
|
Yes, Using the wildcard @utility my-utility-* {
property: --value([*]);
}Then in HTML: Moreover, If you want stricter typing, you can replace * with a specific type, e.g., [length]: |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for much for your quick answers guys! I couldn't get |
Beta Was this translation helpful? Give feedback.
Yep! Use the wildcard
(*)arbitrary value type in--value()and it should work:Otherwise, if you only want to allow a specific type, you can do so, but your class names would need to have the hint too:
https://play.tailwindcss.com/XQVoUlYqM0