如何在Tailwind CSS中禁用暗模式

huangapple go评论49阅读模式
英文:

How disabled dark mode in tailwind css

问题

I'm using the package laravel livewire table ([laravel livewire table][1] on my laravel app (v8).

我正在使用laravel livewire表格包 ([laravel livewire table][1]) 在我的laravel应用程序(v8)上。

I also use tailwind CSS on v3.

我还在v3上使用tailwind CSS。

By default this package add some tailwind class for dark mode on tables. But I don't want to use dark mode. I want my site to stay light whatever the browser configuration.

默认情况下,此包在表格上为暗模式添加了一些tailwind类。但我不想使用暗模式。无论浏览器配置如何,我希望我的网站保持明亮。

I read that I have to set it on tailwind.config.js so I try some things like:

我读到我需要在tailwind.config.js上进行设置,所以我尝试了一些方法,比如:

module.exports = {

    plugins: [require('@tailwindcss/forms')],
    darkMode: false,
};
module.exports = {

    plugins: [require('@tailwindcss/forms')],
    darkMode: 'class',
};
module.exports = {

    plugins: [require('@tailwindcss/forms')],
    darkMode: 'media',
};

No one works for disabling dark mode...

但没有一个方法可以禁用暗模式...

Do you know how to do it?

你知道如何做吗?

英文:

I'm using the package laravel livewire table ([laravel livewire table][1]

[1]: https://github.com/rappasoft/laravel-livewire-tables) on my laravel app (v8).

I also use tailwind CSS on v3.

By default this package add some tailwind class for dark mode on tables. But I don't want to use dark mode. I want my site to stay light whatever the browser configuration.

I read that I have to set it on tailwind.config.js so I try some things like :

module.exports = {

    plugins: [require('@tailwindcss/forms')],
    darkMode: false,
};
module.exports = {

    plugins: [require('@tailwindcss/forms')],
    darkMode: 'class',
};
module.exports = {

    plugins: [require('@tailwindcss/forms')],
    darkMode: 'media',
};

No one works for disabling dark mode...

Do you know how to do it?

答案1

得分: 5

https://github.com/rappasoft/laravel-livewire-tables 包内部使用 dark 模式,因此已配置为以这种方式工作。

您可以始终通过执行类似以下内容的操作来强制使用 light 模式:

module.exports = {
  darkMode: 'class',
  // ...
}

然后在您页面的头部,您可以添加以下小脚本,它将覆盖一切并仅使用 light 模式。

localStorage.theme = 'light'

资源:https://tailwindcss.com/docs/dark-mode#supporting-system-preference-and-manual-selection

英文:

https://github.com/rappasoft/laravel-livewire-tables package uses dark mode in itself, so it is configured to work that way.

The thing you can do is to always force light mode by doing something like this:

module.exports = {
  darkMode: 'class',
  // ...
}

And then in header of your page, you can have this small script that will override everything and just use light mode.

localStorage.theme = 'light'

Resource: https://tailwindcss.com/docs/dark-mode#supporting-system-preference-and-manual-selection

答案2

得分: 4

将 "darkMode: false," 更改为 "darkMode: 'false'," 可以正常工作。

英文:

changes

darkMode: false,

to

darkMode: 'false',

its work for me

huangapple
  • 本文由 发表于 2023年2月14日 18:56:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75446831.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定