我想设置一个不同的文本颜色悬停取决于类别名称与顺风。我设置了一个配置,每个颜色代码引用如下所示的类别:
tailwind.config.js
theme: {
extend: {
}
},
colors: {
transparent: 'transparent',
current: 'currentColor',
"animation": "#A72608",
"decor": "#E0AFA0",
"illustrations": "#32936F",
"developpement-visuel": "#C2FCF7",
"realisations": "#FEEA00",
"croquis": "#9F6BA0",
"white": "#FFFFFF",
},
在我的组件中这样使用:
sidebar.js
<nav>
<ul>
{categories.map((category) => {
return (
<li key={category.id} className="mb-4">
<Link href={`/category/${category.attributes.slug}`}>
<a className={`hover:text-${category.attributes.slug} uppercase font-light text-sm`}
>{category.attributes.name}</a>
</Link>
</li>
)
})}
</ul>
</nav>
但结果证明它不起作用。当我看到devtools ${category.attributes.slug}实际上被替换为类别的名称和我在配置中指定的名称
发布于 2022-03-04 20:29:01
您能否尝试在tailwind.config.js
中设置文本颜色的悬停效果?
module.exports = {
variants: {
textColor: ['group-hover', 'hover'],
}
}
https://stackoverflow.com/questions/71356173
复制相似问题