tailwindcss: The global variable `--tw-transform` is not defined in base
What version of Tailwind CSS are you using?
v3.0.7
What build tool (or framework if it abstracts the build tool) are you using?
tailwindcss-cli 3.0.7
What version of Node.js are you using?
v16.13.0
What browser are you using?
Chrome
What operating system are you using?
macOS
Reproduction URL
https://play.tailwindcss.com/iVIJhwfSBR – Funny thing here: --tw-transform gets directly added to div:after and there is no global definition of that variable. Maybe v3.0.1 is the reason for that 😕
Describe your issue
Edit: It seems like this relates to https://github.com/tailwindlabs/tailwindcss/pull/6500
I am using web components which import a shared CSS file that only contains @tailwind base. When trying to use transform utilities I can also see transform: var(--tw-transform);.
The problem is that the variable is not defined since that does not live in Tailwind base:
*, ::before, ::after {
...
--tw-transform: translateX(var(--tw-translate-x)) translateY(var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
...
}
Is it possible that we get this moved like the other globals like shadows or content?
*, ::before, ::after {
--tw-ring-offset-shadow: 0 0 #0000;
--tw-ring-shadow: 0 0 #0000;
--tw-shadow: 0 0 #0000;
--tw-shadow-colored: 0 0 #0000;
}
::before,
::after {
--tw-content: '';
}
Thank you!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (3 by maintainers)
I have the same issue. I’m using Next.js, Tailwind CSS, twin.macro, and styled-components.
When applying the classes inside the styled-component Div like this, it doesn’t work (with or without the
transformclass) …However, applying the class
-translate-y-1/2directly to the<div>element inside the component does work perfectly 😕<div className="-translate-y-1/2">I’m not sure if it’s a twin.macro issue in my case or is it a configuration issue or what.
In my case, @tailwind base; was not added. After adding transform started working
@adamwathan thanks for your response! The problem in my case is that
--tw-transformis not defined. When trying to userotate-90I get CSS like this ⬇️I’m still wondering about the global CSS that I can see in
tailwind.css⬇️That is not available in my case because I moved the
@tailwind baseinto another file. Also downgrading to v3.0.1 like on play.tailwindcss.com didn’t help 😦I believe this issue is recurring only in NextJS. I tried the same on Svelte and seemed to work as expected. Maybe there’s some overridden postcss config that’s stopping Tailwind to work as it should?