Skip to content

Documentation Improvement Request: @reference Directive Clarity #2374

@richardtallent-erm

Description

@richardtallent-erm

Affected Pages

Problem

The @reference directive documentation states:

"If you're just using the default theme with no customizations, you can import tailwindcss directly"

However, it's unclear that:

  1. Adding any @theme variables (including @theme inline) counts as "customizations"
  2. @reference "tailwindcss" will not include your custom theme variables
  3. 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

  1. In the @reference section, make it more explicit that you can only use use @reference "tailwindcss" if you have no @theme blocks, otherwise you need to use @reference "path/to/your-css-file.css".

  2. Add a callout in the @theme documentation's "Referencing other variables" section:

Note: When using custom theme variables with @apply in 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions