#Tailwind `dark` class doesn't work in frontend

3 messages · Page 1 of 1 (latest)

civic gulch
#

I don't know if I'm missing something, but I just spent a bit of time trying to figure out why this code in my layout didn't swap to my dark mode background:

<div
  className="fixed inset-0 -z-50 w-full h-full dark:bg-[url('/camo-dark.png')] bg-[url('/camo.png')] bg-repeat bg-auto"
  style={{ backgroundAttachment: 'fixed' }}
  aria-hidden="true"
/>

after some trial and error and searching I found I had to add this to tailwind.config.mjs:

  darkMode: 'class',

I would have thought an app that contains a ThemeSelector in its footer by default should already have the correct config for Tailwind.

flint quiver