Replies: 1 comment 3 replies
-
Hey! For places where CSS variables don't work sense, we still have the theme function. You'd use it like |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Why is the theme() function in v4 deprecated? Using only CSS variables makes no sense to me with the use of Lightning CSS. Especially with regard to the mathematical functions of CSS.
One great thing about Lightning CSS is that it can simplify the mathematical functions of CSS. But unfortunately only if no CSS variables are used.
https://lightningcss.dev/transpilation.html#math-functions
Here is an example of a fluid spacing calculation with CSS variables:
CSS Configuration:
var-test-px-20 compiles to:
Here is an example of a calculation of the fluid spacing with theme():
CSS Configuration:
theme-test-px-20 compiles to:
The difference is impressive, isn't it? The root variables are also not required and can therefore be omitted with ‘@theme reference{}’ in the final CSS file. If you still need the CSS variables, you can also create them again in the CSS configuration under ‘’@theme‘’.
And here is another example of the general spacing behaviour of Tailwind v4:
I also wonder why a CSS variable has to be used here.
Here is the compiled code for e.g. px-4:
And here is a customised version for e.g. px-4 with theme():
Why doesn't it work the same way? It's better than inserting the CSS variable every time. There is also no disadvantage because I still have access to a global spacing variable via the CSS configuration. For those who need the CSS variable, an optional function should be available.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions