0.1.0 • Published 5 years ago

tailwindcss-prefers-color-scheme v0.1.0

Weekly downloads
6
License
ISC
Repository
github
Last release
5 years ago

Tailwind CSS prefers color scheme

This plugin for Tailwind CSS adds variants for dark and light modes using the prefers-color-scheme media feature.

Installation

npm install tailwindcss-prefers-color-scheme

Usage

// in tailwind.config.js
{
  variants: [
    backgroundColor: ['responsive', 'light-mode', 'dark-mode']
  ],
  plugins: [
    require('tailwindcss-prefers-color-scheme')()
  ]
}

This would generate classes like the following:

.bg-red-100 {
  background-color: red;
}

@media (prefers-color-scheme: light) {
  .light-mode\:bg-red-100 {
    background-color: red;
  }
}

@media (prefers-color-scheme: dark) {
  .dark-mode\:bg-red-100 {
    background-color: red;
  }
}