我正在尝试将 Craco 与 Ant-Design 一起使用,但我无法制作合适的主题切换器。有没有更简单的方法来为此实现主题切换器?
const CracoLessPlugin = require("craco-less");
const {
getThemeVariables
} = require('antd/dist/theme');
module.exports = {
plugins: [{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: {
"@primary-color": "#1DA57A",
...getThemeVariables({
dark: true,
compact: true
})
},
javascriptEnabled: true
}
}
}
}],
};
最佳答案
在为 antd.less
为了导入深色主题,我这样做了:
@import '~antd/lib/style/themes/dark.less';
@import '~antd/dist/antd.less';
您可以在此处了解更多信息 https://ant.design/docs/react/customize-theme#Customize-in-less-file
关于reactjs - craco 和 antd 的主题切换怎么用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62833759/