Skip to content

A Tailwind CSS plugin for adding variants using the prefers-color-scheme media feature.

Notifications You must be signed in to change notification settings

avdgaag/tailwindcss-prefers-color-scheme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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;
  }
}

About

A Tailwind CSS plugin for adding variants using the prefers-color-scheme media feature.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published