How to make design tokens responsive in Tailwind 4? #17655
Unanswered
katerlouis
asked this question in
Help
Replies: 2 comments 3 replies
-
|
Replace the second @theme {
--spacing-foo: 20px;
}
@media (width > 600px) {
:root {
--spacing-foo: 40px;
}
} |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
But @wongjn replacing the theme with :root is not the good approach with big scaling application, can cause flickers specificity bugs (especially when you use multiple themes or containers). Good approach will be using the sm:, md: if inline className is getting bigger then we can replace it with the @apply |
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
My
--spacing-fooshould be20pxon mobile and40pxon desktop. Nothing fancy;Yet, the following results in 40px across all viewports:
Changing the nesting and putting media query inside
@themedoes not work as it breaks the site.The workaround for that (and I fear the intended workflow) is not satisfactory for me either.
Having to do that everywhere I want to use spacing
foois obnoxious and for goes against the concept of globalized design tokens. Using@md:px-foo-largecan be easily forgotten and adding multiple breakpoints, again globally, requires to go through each and every usage instance and add@lg:px-foo-xlarge.Since I could not find anything regarding this in the docs, I wanted to ask how you would realize the desired behavior?
Beta Was this translation helpful? Give feedback.
All reactions