Setting a Default Font Weight #19822
Replies: 3 comments
-
|
Yep, should be OK. |
Beta Was this translation helpful? Give feedback.
-
|
If you want one class that bundles both the family and the weight, @utility font-display {
font-family: "Example";
font-weight: 700;
}That should not break any Tailwind internals. It just means The distinction is:
So if you want to stay inside Tailwind’s theme model, define |
Beta Was this translation helpful? Give feedback.
-
|
Your A cleaner approach that keeps Tailwind's internals happy is to define the font in the theme and then layer on the weight using a base style or a custom utility that composes them: Option 1: Base layer (recommended if this font always uses weight 700) @theme {
--font-display: "Example";
}
@layer base {
.font-display {
font-weight: 700;
}
}This keeps the theme variable intact, so Option 2: Your Your approach does work fine in practice. It won't break anything at runtime — Tailwind will generate the utility and it'll apply both properties. Just be aware that since you're shadowing the namespace, the theme variable @utility font-display {
font-family: "Example";
font-weight: 700;
}Either way, you won't run into issues. I'd lean toward Option 1 for cleanliness. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey, I'm trying to set a default
font-weightwhenever I use my custom font.So instead of
I'm considering using
This seems simple enough, but I was wondering if this might break any of Tailwind's "behind-the-scenes magic". Is it okay to use the
--font-*namespace in a utility like that?Beta Was this translation helpful? Give feedback.
All reactions