tailwind默认背景颜色在一个新项目中不起作用
我已经在一个新项目中安装了tail风,似乎工作正常。当我尝试将背景黑色应用于身体时,它起作用了:
<body class="bg-black">
但是,当我尝试应用另一种默认颜色时,它不起作用:
<body class="bg-slate-500">
为什么?如何将默认的颜色Parete添加到BG实用程序类中?
//tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
colors: {
},
extend: {},
},
plugins: [
require('@tailwindcss/typography'),
],
}
尾风3.1.4 这是项目repo
I've installed tailwind in a new project and seems work fine. When I try to apply a background black color to the body it works:
<body class="bg-black">
But when I try to apply another default color it doesn't work:
<body class="bg-slate-500">
Why? How can I add the default color palete to bg utility classes?
//tailwind.config.js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
colors: {
},
extend: {},
},
plugins: [
require('@tailwindcss/typography'),
],
}
Tailwind 3.1.4
Here is the project repo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试使用
className
而不是class
try using
className
instead ofclass
为了摆脱弃用的警告,您可以手动删除弃用的颜色:
To get rid of deprecated warnings, you may manually remove deprecated colors:
您要么定义一个颜色对象,该对象可以选择所需的/需要哪种调色板,要么在
tailwind.config.js
中简单地导入默认颜色。https://tailwindcss.com/docs/customizing-colors#using-默认违规曲
按要求更新2
,我包括一个完整的示例,说明在何处将导入的颜色包含在尾风CSS配置文件中。
You'll want to either define a colors object that pick which color palettes you want/need or simply import the default colors in your
tailwind.config.js
.https://tailwindcss.com/docs/customizing-colors#using-the-default-colors
Update 2
As asked, I'm including a full example of where to include the imported colors in the Tailwind CSS config file.