Repository navigation
Replies: 1 comment 2 replies
|
Hey! I'm going to do some more research on this one. Somebody opened a PR with a solution that kind of tries to solve the same issue. I think there is a path forward where both can be used. Relevant PR: #20274 I'll come back with some research to figure out the APIs and feasibility of these feature(s). |
2 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.
The gap
In v4 the
prefixset via@import "tailwindcss" prefix(tw)is global and all-or-nothing: every generated utility requires the prefix (tw:flex), and there's no way to tell Tailwind to scan a specific@sourcewith a different prefix (or none). That makes prefixed apps and third-party Tailwind libraries hard to combine, in two mirror-image ways:1. Consuming a library that ships unprefixed classes. A headless/render-prop library ships
class="flex items-center"in its dist and asks you to@sourceit. Under a global prefix, only prefixed tokens generate, so none of the library's classes produce CSS and the components render unstyled:Concrete case: kcsujeet/ilamy-calendar#111
2. Consuming a library that ships prefixed classes. A library built with its own prefix (
sb:flex) can't be scanned by an app looking for unprefixed tokens, and tree-shaking breaks, forcing consumers to import the library's whole prebuilt CSS. See #19684 and #19498.Both are the same root cause: the prefix can't be scoped per source.
Why the current options don't close it
prefixis the only knob;@sourcehas no prefix parameter.@source inline(...)can safelist utilities, but it's unwieldy for a whole library's class set and (as far as I understand) still emits under the global prefix (confirmation welcome).Idea
A per-
@sourceprefix control so the prefix is scoped, not global. Strawman (open to any shape that fits the design):This would let prefixed apps consume any Tailwind-based library without the library having to know the consumer's prefix, and would restore tree-shaking for prefixed libraries.
Related
#19645 (broader component-library ecosystem proposal, from the "each library uses its own prefix" angle), #19684, #19498, #17242. Several recurring Help threads suggest real demand.
Questions
All reactions