next-themes icon indicating copy to clipboard operation
next-themes copied to clipboard

Documentation out of date with Tailwind's new dark-mode API

Open MichaelAllenWarner opened this issue 1 year ago • 4 comments

Tailwind recently changed their dark-mode API:

  • The default "media" strategy remains unchanged.
  • The "class" strategy (mentioned in the next-themes README) still exists for backward-compatibility, and under the hood it still does addVariant('dark', `:is(${selector} &)`).
  • The new "selector" strategy is meant to replace the "class" strategy going forward. It behaves similarly, but it has reduced specificity and is a little more flexible: addVariant('dark', `&:where(${selector}, ${selector} *)`).
  • The new "variant" strategy allows for total customization of the dark: variant: addVariant('dark', selector).

The new strategies aren't yet documented on the Tailwind website, but they were shipped in v. 3.4.1. (A slightly different version shipped in 3.4.0, but it had problems.)

The README for this repository should probably be updated accordingly.

MichaelAllenWarner avatar Feb 06 '24 14:02 MichaelAllenWarner