Alternatively, use CSS var's with a JS framework:
When I was working with Tailwind and Svelte for the first time, I was looking for a solution to this, and I found that you can use the style attribute:
<script>
let cssVariables = {
'primary-color': "#ffffff",
'secondary-color': "#000"
}
let styleValues = Object.entries(cssVariables)
.map(([key, value]) => `--${key}:${value}`)
.join(';')
</script>
<p style={styleValues}
class="text-center text-[4vmax] text-[color:var(--primary-color)]">
Hello World
</p>
The code above makes a object, this object is converted to a string that works like pure CSS, every property is joined to that string.
This works, assuming that you're in Svelte, although, in HTML doesn't.
If you want to use Tailwind with HTML, you must write the whole string:
<p style="--primary-color:#ffffff;--secondary-color:#000"
class="text-[4vmax] text-center text-[color:var(--primary-color)]">
Hello World
</p>
So, I recommend you use a framework that help you use data binding. Also, there're other things that you can do with this trick, like reactive CSS (below, in the Svelte way):
<script>
$: changingHue = 0
setInterval(() => changing_hue++, 250)
$: cssVariables = {
'primary-color': `hsl(${changingHue} 100% 70%)`,
'secondary-color': "#000"
}
$: styleValues = Object.entries(cssVariables)
.map(([key, value]) => `--${key}:${value}`)
.join(';')
</script>
<p style={styleValues}
class="text-center text-[4vmax] text-[color:var(--primary-color)]">
Hello World
</p>
In conclusion, you don't need another library to make Tailwind use CSS variables, just Javascript and even HTML is enough.