[v4] How to have tailwind css vars applied not to :root? #18108
Unanswered
artaommahe
asked this question in
Help
Replies: 1 comment 3 replies
-
You don't have this option. If you use a PostCSS plugin, you can manipulate the output and replace If you don't want to do that, then I think the feature you're looking for is the prefix; that way, TailwindCSS classes won't conflict with other classes - for example, with Bootstrap if you're migrating from it.
|
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.
-
We're migrating from js-based config to tailwind-based. We have a specific case when two sets of tailwind tokens (two different themes) exist on the same page together - we're slowly migrating from the old design to the new one.
With js-based config we've resolved conflicts with adding
important: '.new_design'
to the second config and nesting all new components under.new_design
class. We're not using prefixes cause they make dx worse and we want to use regular tailwind classes likep-5 text-primary
everywhere, but they should have different values for different components/themes.With css-based config im trying to do smthing similar for the new design theme
Note the
initial
modifier on@theme
- without it tailwind sets tailwind-related css vars on:root {}
and they conflict with similarly named css vars from another config https://play.tailwindcss.com/MD1r1Zwm36?file=css.Using inline works fine in general, but it doesn't allow us to use tailwind-related css variables, like
var(--text-color-primary)
, in js code https://tailwindcss.com/docs/upgrade-guide#theme-values-in-javascript or in css modules (especially to map some library's css vars to tailwind css vars) https://tailwindcss.com/docs/upgrade-guide#using-apply-with-vue-svelte-or-css-modules, cause those tailwind css vars are not set for the inlined theme.Question: how to tell tailwind to set tailwind-related variables not on the
:root {}
but on some specified selector?Beta Was this translation helpful? Give feedback.
All reactions