Чтобы получить цвета Tailwind CSS в JavaScript, вы можете использовать следующие методы:
-
Используйте объект
colorsиз файла конфигурации CSS Tailwind по умолчанию:const colors = require('tailwindcss/colors'); console.log(colors); // Prints the entire colors object console.log(colors.blue[500]); // Prints the hex value of Tailwind's blue-500 color -
Импортировать определенные цвета непосредственно из CSS Tailwind:
import { blue } from 'tailwindcss/colors'; console.log(blue[500]); // Prints the hex value of Tailwind's blue-500 color -
Используйте функцию
resolveConfigиз пакетаtailwindcss, чтобы получить разрешенную конфигурацию CSS Tailwind, включая цвета:const resolveConfig = require('tailwindcss/resolveConfig'); const tailwindConfig = require('./tailwind.config.js'); const { theme } = resolveConfig(tailwindConfig); console.log(theme.colors); // Prints the entire colors object console.log(theme.colors.blue[500]); // Prints the hex value of Tailwind's blue-500 color
Используя эти методы, вы можете получить доступ к цветовой палитре CSS Tailwind непосредственно в JavaScript.