Adding a custom prefix for tailwind 4.0 #16046
Replies: 3 comments 6 replies
-
@DennisVulders how do you set the prefix? |
Beta Was this translation helpful? Give feedback.
-
@DennisVulders Just tested your theory and this is working for me.
|
Beta Was this translation helpful? Give feedback.
-
The prefix became a variant starting from v4, so Tailwind can now apply it at the very beginning of every class name. For example, in v3: From a readability standpoint, it's debatable which approach is better, but in terms of functionality, handling it as a variant fits much more naturally into the TailwindCSS syntax than the v3-style prefix. I believe this won't change from v4 onward, and it won't be possible to revert to using the old prefixes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey All,
We are currently upgrading our code from tailwind 3 to tailwind 4 and we (like many others) use the "tw-" prefix. While after searching for a while i did find out that prefixes can be added but it would then be used as tw:width-full for example. To make tailwind 4 more backwards compatible and in my personal opinion i think the readability of the "tw:" is worse than the "tw-" prefix, since the classes themselves are also kebab-case.
I know that we can still use the old config to do this, but it would be ideal if it is possible to use:
@import "tailwindcss" prefix(tw-);
So that we can all use tw-w-full etc.Hopefully this can be a feature in a future release of tailwind 4.x 🙂
Beta Was this translation helpful? Give feedback.
All reactions