How to make design tokens responsive in Tailwind 4? #17655
Unanswered
katerlouis
asked this question in
Help
Replies: 1 comment
-
Replace the second @theme {
--spacing-foo: 20px;
}
@media (width > 600px) {
:root {
--spacing-foo: 40px;
}
} |
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
-
My
--spacing-foo
should be20px
on mobile and40px
on desktop. Nothing fancy;Yet, the following results in 40px across all viewports:
Changing the nesting and putting media query inside
@theme
does 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
foo
is obnoxious and for goes against the concept of globalized design tokens. Using@md:px-foo-large
can 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