Skip to content

Is it possible to prefix --tw CSS variables? #10697

Answered by htor
htor asked this question in Help
Discussion options

You must be logged in to vote

I made this manual workaround using postcss-replace in my project.

postcss.config:

module.exports = {
  plugins: {
    'postcss-import': {},
    tailwindcss: {},
    autoprefixer: {},
    'postcss-replace': {
      pattern: /(--tw|\*, ::before, ::after)/g,
      data: {
        '--tw': '--mylib-tw', // Prefixing
        '*, ::before, ::after': ':root', // So variables does not pollute every element
      }
    }
  },
}

Would be best if TW provided a way to do this itself, though

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by htor
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
3 participants