Tailwindcss: Add tailwind prefix during build

Created on 10 May 2020  路  2Comments  路  Source: tailwindlabs/tailwindcss

I currently have a custom Vue component library which uses tailwindcss. To avoid naming collisions with other libs I currently use a custom tailwind prefix.

If I want to use a tailwind UI component I always have to add my prefix manually for all the tailwind classes (so I can't simple copy and paste the code).

So I'm wondering: What's the best strategy to deal with such naming collisions? Is there a way to prefix tailwind classes during build time, to avoid adding prefixes manually all the time?

Most helpful comment

We're going to fix this at the Tailwind UI level by making it possible to add a prefix to the code snippets 馃憤 No plans for a template processing thing built into Tailwind though I'm afraid.

All 2 comments

What if you're using Tailwind and another library that also uses a common class, like .my-4 (Bootstrap, for example).

If you don't prefix before building, how would the build system know what class to prefix?

You could use a tool like VS Code Intellisense to prefix it for you while you develop https://github.com/bradlc/vscode-tailwindcss/issues/104

We're going to fix this at the Tailwind UI level by making it possible to add a prefix to the code snippets 馃憤 No plans for a template processing thing built into Tailwind though I'm afraid.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tjoosten picture Tjoosten  路  3Comments

lamberttraccard picture lamberttraccard  路  3Comments

smbdelse picture smbdelse  路  3Comments

jbardnz picture jbardnz  路  3Comments

rgaufman picture rgaufman  路  3Comments