Support @theme reference
without @import
#13222
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for using
@theme reference { … }
as a way to define theme values that you don't want emitted in the final CSS but do want to be used as a source of truth for utility values.This fleshes out what we already loosely supported with
@import "./my-theme.css" reference
, while fixing some bugs we actually had in that implementation surrounding multiple@theme
definitions.The main motivating use case for this is to support having access to your theme in CSS module scopes like Vue's
<style>
blocks, where you may want to use@apply
:For
@apply
to work here it's necessary for your theme values to be "in scope" from Tailwind's perspective, and since all of these<style>
blocks are processed completely independently, Tailwind has no idea what theme values you're using in your global CSS file when this block is processed.This also makes it possible for people to suppress the output of all of the CSS variables if that's something they want to do, but this isn't a use case I personally think makes sense to advertise — I think we should be opinionated about pushing people to want to output these variables so they can access their theme values with
var(…)
in arbitrary values or in JS contexts.