我的自定义颜色“主要”在构建模式下不起作用并消失。但是在开发模式下它存在。
tailwind.config.js
module.exports = {
purge: ["./src/**/*.{js,jsx,ts,tsx}", "./public/index.html"],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {
colors: {
primary: "#C62C2C",
secondary: "#6558f5",
dark: "#000000",
},
},
fontFamily: {
body: ["Inter", "sans-serif"],
},
},
variants: {
extend: {},
},
plugins: [],
};
按钮组件
const Button = (props) => {
return (
<button
className={`rounded-lg ${props.className ? props.className : "1"} ${
props.padding
} text-sm text-white bg-${props.color}`}
onClick={props.onClick}
>
{props.children}
</button>
);
};
调用按钮组件
<Button color="primary" padding="px-6 py-2"></Button>