-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtailwind.config.js
33 lines (30 loc) · 951 Bytes
/
tailwind.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/** @type {import('tailwindcss').Config} */
const plugin = require('tailwindcss/plugin');
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [
plugin(function({ addBase, theme }) {
const colors = theme('colors'); // Get all colors from the Tailwind theme
const root = {};
// Loop through the colors and create CSS variables
for (const [colorName, colorValue] of Object.entries(colors)) {
if (typeof colorValue === 'string') {
root[`--${colorName}`] = colorValue; // For single hex values
} else if (typeof colorValue === 'object') {
for (const [shade, hex] of Object.entries(colorValue)) {
root[`--${colorName}-${shade}`] = hex; // For shades of colors like red-500
}
}
}
// Add the variables to the :root selector
addBase({
':root': root,
});
}),
],
}