-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Affected Pages
- https://tailwindcss.com/docs/functions-and-directives#reference-directive
- https://tailwindcss.com/docs/theme#referencing-other-variables
Problem
The @reference directive documentation states:
"If you're just using the default theme with no customizations, you can import
tailwindcssdirectly"
However, it's unclear that:
- Adding any
@themevariables (including@theme inline) counts as "customizations" @reference "tailwindcss"will not include your custom theme variables- You must switch to referencing your actual CSS file path when using custom themes
Using @reference "tailwindcss" when you have custom @theme variables results in "Cannot apply unknown utility class" errors when trying to use those custom utilities in @apply directives. The error message suggests adding @reference but doesn't clarify that @reference "tailwindcss" is insufficient in this case.
Suggested Improvements
-
In the
@referencesection, make it more explicit that you can only use use@reference "tailwindcss"if you have no@themeblocks, otherwise you need to use@reference "path/to/your-css-file.css". -
Add a callout in the
@themedocumentation's "Referencing other variables" section:
Note: When using custom theme variables with
@applyin component styles, you must use@reference "path/to/your-css-file.css"(not@reference "tailwindcss") to access those variables. See the @reference directive documentation for details.
Why This Matters
Developers expect @reference "tailwindcss" to mean "give me access to all available Tailwind utilities for this project," but it actually means "give me only the default built-in theme, ignoring customizations." This mental model mismatch causes confusion and difficult-to-debug build errors, especially for projects using dynamic theming patterns.