Custom font doesn't work with css var #18073
-
What version of Tailwind CSS are you using? For example: v4.1.7 What build tool (or framework if it abstracts the build tool) are you using? N.A What version of Node.js are you using? v22.14.0 What browser are you using? Firefox What operating system are you using? macOS Reproduction URL https://play.tailwindcss.com/Wqb57TyO7w Describe your issue As you can see in the example, only |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey! This is because the default text reads the CSS variable from If you want the default text to be set, hoist the custom font up, e.g. in |
Beta Was this translation helpful? Give feedback.
Hey!
This is because the default text reads the CSS variable from
:root
, but you define the variable somewhere nested in the tree. So at the time of reading the variable for the default--font-mono
it's still the default monospaced value not the new one you set deeply nested.If you want the default text to be set, hoist the custom font up, e.g. in
:root
: https://play.tailwindcss.com/AHhxHtJmP7?file=css