
Security News
Lovable’s OJ Rewrites Vite’s Dev Server in Rust as AI Lowers the Cost of Forking Open Source
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.
tailwind-variants
Advanced tools
The power of Tailwind combined with a first-class variant API.
For full documentation, visit tailwind-variants.org
❕ Note:
Tailwindcss V4no longer supports theconfig.content.transformso we remove theresponsive variantsfeatureIf you want to use
responsive variants, you need to add it manually to your classname.
yarn add tailwind-variants
# or
npm i tailwind-variants
# or
pnpm add tailwind-variants
Optional: If you want automatic conflict resolution, also install tailwind-merge:
yarn add tailwind-merge
# or
npm i tailwind-merge
# or
pnpm add tailwind-merge
💡 Lite mode (v3): For smaller bundle size and faster runtime without conflict resolution, use the
/liteimport:import {tv} from "tailwind-variants/lite";
⚠️ Upgrading?
- From v2 to v3: See the v3 migration guide
- From v1 to v2: See the v2 migration guide
import {tv} from "tailwind-variants";
const button = tv({
base: "font-medium bg-blue-500 text-white rounded-full active:opacity-80",
variants: {
color: {
primary: "bg-blue-500 text-white",
secondary: "bg-purple-500 text-white",
},
size: {
sm: "text-sm",
md: "text-base",
lg: "px-4 py-3 text-lg",
},
},
compoundVariants: [
{
size: ["sm", "md"],
class: "px-3 py-1",
},
],
defaultVariants: {
size: "md",
color: "primary",
},
});
return <button className={button({size: "sm", color: "secondary"})}>Click me</button>;
cva (Joe Bell)
This project as started as an extension of Joe's work on cva – a great tool for generating variants for a single element with Tailwind CSS. Big shoutout to Joe Bell and contributors you guys rock! 🤘 - we recommend to use cva if don't need any of the Tailwind Variants features listed here.
Stitches (Modulz)
The pioneers of the variants API movement. Inmense thanks to Modulz for their work on Stitches and the community around it. 🙏
We're excited to see the community adopt HeroUI, raise issues, and provide feedback. Whether it's a feature request, bug report, or a project to showcase, please get involved!
Contributions are always welcome!
Please follow our contributing guidelines.
Please adhere to this project's CODE_OF_CONDUCT.
Licensed under the MIT License.
See LICENSE for more information.
clsx is a utility for constructing `className` strings conditionally. It is similar to tailwind-variants in that it helps manage class names dynamically, but it does not provide built-in support for Tailwind CSS variants or themes.
classnames is another utility for conditionally joining class names together. Like clsx, it helps manage class names dynamically but lacks the specific Tailwind CSS variant and theme support provided by tailwind-variants.
twin.macro is a library that allows you to use Tailwind CSS with styled-components or emotion. It provides a way to manage Tailwind CSS classes within JavaScript, but it focuses more on integrating Tailwind with CSS-in-JS solutions rather than managing variants and themes.
FAQs
🦄 Tailwindcss first-class variant API
The npm package tailwind-variants receives a total of 2,070,970 weekly downloads. As such, tailwind-variants popularity was classified as popular.
We found that tailwind-variants demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.

Security News
Lovable’s OJ rewrites Vite’s dev server in Rust, reducing memory use and preview times as AI lowers the cost of open source reimplementation.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.