Hi, I’m trying to apply some dark theme based on the browser’s mode, but I can’t make it work.
The strange thing is that it works when I use text-zinc-950 dark:text-zinc-200
but it doesn’t with bg-gray-50 dark:bg-zinc-950
.
Body in root.html.heex
<body class="bg-gray-50 dark:bg-zinc-950 text-zinc-950 dark:text-zinc-200 antialiased">
In the running application from app.css
@media (prefers-color-scheme: dark) {
.dark\:text-green-400 {
--tw-text-opacity: 1;
color: rgb(74 222 128 / var(--tw-text-opacity));
}
.dark\:text-red-400 {
--tw-text-opacity: 1;
color: rgb(248 113 113 / var(--tw-text-opacity));
}
.dark\:text-zinc-200 {
--tw-text-opacity: 1;
color: rgb(228 228 231 / var(--tw-text-opacity));
}
}
there are no dark backgrounds.
Am I missing something?
My deps:
defp deps do
[
{:bcrypt_elixir, "~> 3.0"},
{:phoenix, "~> 1.7.2"},
{:phoenix_ecto, "~> 4.4"},
{:ecto_sql, "~> 3.6"},
{:postgrex, ">= 0.0.0"},
{:phoenix_html, "~> 3.3"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
{:phoenix_live_view, "~> 0.18.16"},
{:floki, ">= 0.30.0", only: :test},
{:phoenix_live_dashboard, "~> 0.7.2"},
{:esbuild, "~> 0.7", runtime: Mix.env() == :dev},
{:tailwind, "~> 0.2.0", runtime: Mix.env() == :dev},
{:swoosh, "~> 1.3"},
{:finch, "~> 0.13"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:gettext, "~> 0.20"},
{:jason, "~> 1.2"},
{:plug_cowboy, "~> 2.5"}
]
end