Skip to content

Problem understanding the concept of @layer and @theme in tailwind 4 #18064

Answered by wongjn
Der-Alex asked this question in Help
Discussion options

You must be logged in to vote

Quick solution

You might as well skip the --color-primary intermediary and use --primary directly. Or otherwise use --theme() which would "embed" the value of the --color-primary token (like what inline does): https://play.tailwindcss.com/kzGRhuAzkd?file=css

Explanation

.custom references --color-primary. The CSS engine searches up the HTML tree until it finds its definition. It finds it on :root/<html>. The value is var(--primary, #abc123). The engine then searches up the HTML from :root/<html> for var(--primary). It doesn't find it and thus uses fallback #abc123.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Der-Alex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants