Skip to content

Removing/reducing unused --tw css custom variables #13828

Closed Answered by adamwathan
jpduckwo asked this question in Help
Discussion options

You must be logged in to vote

You might find this article I wrote a few years ago interesting:

https://adamwathan.me/composing-the-uncomposable-with-css-variables/

It explains in detail how the empty variable stuff works and what we use it for 👍 We have to set it on every single element (*) rather than :root because CSS variables are inherited, and we need to make sure that they are reset for every element otherwise you get unexpected results.

Consider a simplified example of some of what Tailwind does:

* {
  --tw-translate-x: ;
  --tw-translate-y: ;
}

.translate-x-4 {
  --tw-translate-x: translateX(1rem);
  transform: var(--tw-translate-x) var(--tw-translate-y);
}

.translate-y-8 {
  --tw-translate-x: translateX(2rem)…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jpduckwo
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants