How to extend theme with TwMerge in Tailwind v4 #521
-
How do I do this in Tailwind v4 without the config.js file?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @JacobArrow! 👋 I know it is repetitive, but I think the best way to do it is to just hardcode the font sizes into the tailwind-merge config, possibly using validators. E.g. if you're using a number scale like import { extendTailwindMerge, validators } from 'tailwind-merge'
const twMerge = extendTailwindMerge({
override: {
theme: {
text: [validators.isNumber],
},
},
}) Then you don't need to touch the tailwind-merge config if you add more font-size variables that are essentially just new numbers on the scale. If you use specific names that don't match any validator, e.g. import { extendTailwindMerge, validators } from 'tailwind-merge'
const twMerge = extendTailwindMerge({
override: {
theme: {
text: ['tiny', 'small', 'medium', 'large', 'huge'],
},
},
}) |
Beta Was this translation helpful? Give feedback.
Hey @JacobArrow! 👋
I know it is repetitive, but I think the best way to do it is to just hardcode the font sizes into the tailwind-merge config, possibly using validators.
E.g. if you're using a number scale like
--text-1
,--text-2
, etc. you can just use a config like this:Then you don't need to touch the tailwind-merge config if you add more font-size variables that are essentially just new numbers on the scale.
If you use specific names that don't match any validator, e.g.
--text-tiny
,--te…