tailwindcss-global-dark

1.0.1 • Public • Published

npm version npm downloads license build size

A TailwindCSS variant for class-based dark mode with CSS modules.

In popular frameworks like Svelte, stylesheets are scoped with CSS modules by default. Using @apply dark:text-white in a scoped stylesheet will produce incorrect CSS for the class-based dark mode on TailwindCSS.

tailwindcss-global-dark introduces a gdark variant that adds the :global modifier to the .dark class used by TailwindCSS.

<style lang="postcss">
  .incorrect {
    @apply dark:bg-red-400
    /* compiles to .dark.svelte-1847890 .correct.svelte-1847890 */
  }

  .correct {
    @apply gdark:bg-green-400;
    /* compiles to .dark .correct.svelte-1847890 */
  }
</style>

Installation

$ npm i tailwindcss-global-dark

Add the plugin to tailwind.config.cjs:

module.exports = {
  ...
  theme: { ... },
  plugins: [require('tailwindcss-global-dark')]
};

Package Sidebar

Install

npm i tailwindcss-global-dark

Weekly Downloads

23

Version

1.0.1

License

MIT

Unpacked Size

3.84 kB

Total Files

4

Last publish

Collaborators

  • bryanmylee