繁体   English   中英

获取在 js 中的 tailwind 配置文件中定义的自定义 colors(`colors` 对象)

[英]Get custom colors defined on tailwind config file in js (`colors` object)

我在 tailwind.config.js 文件中定义了一些自定义的 colors。

module.exports = {
    darkMode: 'class',
    content: [
        './src/**/*.{js,jsx,ts,tsx,html}',
        './public/index.html'
    ],
    theme: {
        extend: {
            colors: {
                primary: '#E3106E',
                gp: '#19AAF8',
                bl: '#F56622',
                airtel: '#EC1C24',
                robi: '#E30B13',
                teletalk: '#6EB344'
            }
        },
        plugins: []
    },
    gpColor: '#19AAF8'
}

在js文件中,我可以从tailwind CSS导入的colors变量中得到tailwind colors。有没有办法在js文件中得到自定义的colors?

您可以将其应用为

import colors from 'tailwindcss/path'
const green = colors.primary;

这可能对你有帮助。

供参考:- 第二件事是,如果您使用的是 tailwind CSS,那么您可以直接在您的代码上使用他们自己的 CSS colors。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM