tailwindcss-theme-variants weekly downloads statistics
By JakeNavith · npm · Tailwind plugins
Media-query- or JavaScript-based theme variants with fallback for Tailwind CSS
tailwindcss-theme-variants has 1,248 recorded weekly downloads on npm, an increase of 15.2% over the past 30 days, ranking #2020 of 3,247 tracked listings.
About tailwindcss-theme-variants
🌗 Tailwind CSS Theme Variants
This Tailwind CSS plugin registers variants for theming beyond just light and dark modes without needing custom properties. It has support for
- Controlling themes with
- Media queries, like
prefers-color-scheme,print, or anything you want - CSS selectors, like classes and data attributes
- Or both at the same time!
- Media queries, like
- Responsive variants
- Stacking on extra variants, like
hoverso you can change a link's hover color depending on the theme - Falling back to a certain theme when no other one could become active, like if a visitor's browser doesn't support JavaScript or the new
prefers-media queries - As many themes as you want: light theme, dark theme, red theme, blue theme—just bring your own definitions! The experimental
semanticsfeature makes multiple themes easy to deal with!
You are recommended to check out the comparison table of all Tailwind CSS theming plugins below before committing to any one. By the way, you might have noticed this plugin's documentation / README is very long—don't let that frighten you! I designed it to be overdocumented and as exhaustive as possible, and since most of it is long code snippets, it's shorter than it looks and you don't need to go through it all to do well!
What about Tailwind's upcoming official dark mode?
This plugin will still be maintained! Light and dark mode support is just one thing this plugin can do, and the complexity this plugin can provide will not be reflected in Tailwind core (see Design Rationale), so I will still need this around.
⬇️ Installation
npm install --save-dev tailwindcss-theme-variants
🛠 Basic usage
Using selectors to choose the active theme
With this Tailwind configuration,
const { themeVariants } = require("tailwindcss-theme-variants");
module.exports = {
theme: {
backgroundColor: {
"gray-900": "#1A202C",
},
},
variants: {
backgroundColor: ["light", "dark"],
},
plugins: [
themeVariants({
themes: {
light: {
selector: ".light-theme",
},
dark: {
selector: ".dark-theme",
},
},
}),
],
};
this CSS is generated:
.bg-gray-900 {
background-color: #1A202C
}
/* If you're having trouble understanding,
imagine it said html instead of :root,
like in the example HTML below */
:root.light-theme .light\:bg-gray-900 {
background-color: #1A202C
}
:root.dark-theme .dark\:bg-gray-900 {
background-color: #1A202C
}
After also enabling "light" and "dark" variants for textColor and bringing in more colors from the default palette, we can implement a simple themed button in HTML like this:
<html class="light-theme"> <!-- Change to dark-theme -->
<button class="light:bg-teal-200 dark:bg-teal-800
light:text-teal-700 dark:text-teal-100">
Sign up
</button>
</html>
This will result in dark blue text on a light blue background in the light theme, and light blue text on a dark blue background in the dark theme.
💡 You can choose more than just classes for your selectors. Other, good options include data attributes, like [data-padding=compact]. You can go as crazy as .class[data-theme=light]:dir(rtl), for example, but I think that's a bad idea!
Using media queries to choose the active theme
You may rather choose to tie your theme selection to matched media queries, like prefers-color-scheme:
const { themeVariants, prefersLight, prefersDark } = require("tailwindcss-theme-variants");
module.exports = {
theme: {
backgroundColor: {
"teal-500": "#38B2AC",
},
},
variants: {
backgroundColor: ["light", "dark"],
},
plugins: [
themeVariants({
themes: {
light: {
mediaQuery: prefersLight /* "@media (prefers-color-scheme: light)" */,
},
dark: {
mediaQuery: prefersDark /* "@media (prefers-color-scheme: dark)" */,
},
},
}),
],
};
Which generates this CSS:
.bg-teal-500 {
background-color: #38B2AC
}
@media (prefers-color-scheme: light) {
.light\:bg-teal-500 {
background-color: #38B2AC
}
}
@media (prefers-color-scheme: dark) {
.dark\:bg-teal-500 {
background-color: #38B2AC
}
}
Keep the variants listed in the same order as in themes in this plugin's configuration for consistency and the most expected behavior: in backgroundColor's variants, light came first, then dark, so we also list light before dark in themeVariants's themes option.
💡 The group feature will take care of this for you!
⚙️ Full configuration
This plugin expects configuration of the form
{
group?: string,
themes: {
[name: string]: {
// At least one is required
selector?: string,
mediaQuery?: string,
},
},
baseSelector?: string,
fallback?: boolean | "compact",
variants?: {
[name: string]: (selector: string) => string,
},
}
Where each parameter means:…
Description from the npm listing.
- plugin
- tailwind
- tailwindcss
- tailwindcss-plugin
- tailwindcss-theme
- tailwindcss-themes
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (592)Similar npm Tailwind plugins plugins
All 20 tailwindcss-theme-variants alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/tailwindcss-theme-variants. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.