# tailwind-variants — card for AI agents

Compose Tailwind CSS classes conditionally with a variant-first composition API.

Category: Styling and CSS · npm package `tailwind-variants` · latest version 4.0.1 (checked 2026-11-01)
Install: `npm install tailwind-variants`
License: MIT (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (paste into AGENTS.md or CLAUDE.md)

## Tailwind Variants
- Import from `tailwind-variants` when conflicting Tailwind classes must merge. Use `tailwind-variants/lite` only when merging is not needed.
- On v3.3+, do not install `tailwind-merge` just for this library. Keep it only if the app imports it directly.
- Use `cn` for everyday merging, `cx` in lite or when classes cannot conflict, and `cnMerge` when a call needs its own config.
- Teach the resolver about custom utilities with `twMergeConfig` in `{ extend, override }` form. Never pass a merge function.
- Define variants inline in `tv`, or mark external variant objects `as const`, so types are inferred.
- On Tailwind v4, write breakpoint prefixes (`sm:`, `md:`) directly in class strings. There is no responsive variant API.
- Give a recipe at most one `extend` parent. Add `slots: {}` only when you need slot functions.

## Docs written for agents
- [llms.txt (index of the docs)](https://tailwind-variants.org/llms.txt)

## What it is
- Tailwind Variants is a variant API for Tailwind CSS. It is published as `tailwind-variants` on npm under the MIT license. The GitHub repository was created on 2023-01-12 and sits under the HeroUI organization. The README lists Junior Garcia and Tianen Pang as authors. The Introduction credits Pang with API design and early library work, Garcia with building the library and docs, and Mark Skelton with ongoing maintenance.
- You call `tv()` once to describe a component. The docs say you define "base styles, variants, defaults, and compound rules" and then "call it anywhere with typed props". Without slots, the recipe returns a plain class string. Adding `slots: {}` switches it to slot functions. The default import merges conflicting Tailwind classes, and the `tailwind-variants/lite` import leaves merging out.
- The README says the project started as an extension of cva. The comparison page pitches Tailwind Variants for people who want slots, built-in merge and compound slots, "especially for component libraries like HeroUI".

## Caveats
- Responsive variants are gone on Tailwind v4: The README notes that Tailwind CSS v4 dropped `config.content.transform`, so responsive variants were removed. You add breakpoint classes to your class names yourself.
- Not every helper merges: `cx` only concatenates class names. In the lite build, `cx` is the only one of the three helpers available, so conflicting classes stay side by side.
- One extend parent per recipe: A recipe can inherit from only one other recipe. To combine several bases, you chain extends or join class strings by hand.
- Merge config has limits: `twMergeConfig` takes an `{ extend, override }` object. The README says merge functions and full default configs cannot be passed directly.
- External variant objects need `as const`: Type inference can miss variants that are defined outside `tv`. The FAQ says to define them inline or mark them `as const`.

## Numbers (AgentGid data)
- Gid Score: 60.4 (#995 of all tools, 9 of 53 in its category)
- Used in 45 public projects set up for AI coding agents (0.7%)
- Downloads last week: 7,365,193 (as of 2026-11-24), +56.8% over 4 weeks
- GitHub stars: 3,335 (as of 2026-11-24)
- Last push: 2026-11-10

## Often used with
Tailwind Merge 88.9%, clsx 86.7%, Tailwind CSS 100.0%, tw-animate-css 62.2%, Svelte 55.6%, svelte-check 55.6%

## Checked alternatives (same job)
- Tailwind Merge: https://agentgid.com/tools/tailwind-merge/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/tailwind-variants/
- Homepage: https://github.com/heroui-inc/tailwind-variants#readme
- Repository: https://github.com/heroui-inc/tailwind-variants
- Source: https://github.com/heroui-inc/tailwind-variants#readme
- Source: https://github.com/heroui-inc/tailwind-variants
- Source: https://github.com/heroui-inc/tailwind-variants/releases
- Source: https://tailwind-variants.org/llms.txt
- Source: https://www.tailwind-variants.org/docs/comparison.md
- Source: https://www.tailwind-variants.org/docs/faq.md
- Source: https://www.tailwind-variants.org/docs/introduction.md

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
