Tailwind 深色模式不适用于前缀,为什么?
在我使用前缀之前,我可以正常使用暗模式,但是在我的顺风类中添加前缀后,我不能再使用暗模式了,有人知道如何使用前缀切换暗模式吗?
before I use the prefix , I could use dark mode normally , but after made a prefix to my tailwind classes , I cannot use the dark mode no longer , anyone know how to toggle dark mode with prefix ?, please
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的前缀也需要出现在深色模式类中。
下面的示例假设您将
tw
作为配置的前缀,如果您不需要
dark
类的前缀,则调整配置:-这将允许您切换到 dark不添加前缀的模式
Your prefix needs be there in the dark mode class as well.
the below example assumes you have
tw
as configured prefixif you don't want the prefix for the
dark
class then tweak the config:-this will allow you to switch to dark mode without adding the prefix
唯一对我有用的是@servetoz 响应。您应该在 tailwind.config.js 中设置
darkMode: ['class', '[class*="dark"]']
The only thing that worked for me was @servetoz response. You should set
darkMode: ['class', '[class*="dark"]']
in tailwind.config.js