{
 "kind": "tool",
 "slug": "tailwind-merge",
 "path": "tools/tailwind-merge/",
 "name": "Tailwind Merge",
 "maker": null,
 "density": "full",
 "crumbs": [
  [
   "Tools",
   "tools/"
  ],
  [
   "Styling and CSS",
   "tools/styling/"
  ]
 ],
 "lead": "Let the last Tailwind style win.",
 "chips": [
  {
   "label": "Styling and CSS",
   "path": "tools/styling/"
  },
  {
   "label": "NPM"
  }
 ],
 "primary": {
  "label": "Copy install command",
  "copy": "npm install tailwind-merge"
 },
 "links": [
  {
   "label": "GitHub",
   "href": "https://github.com/dcastil/tailwind-merge"
  },
  {
   "label": "Website",
   "href": "https://github.com/dcastil/tailwind-merge"
  }
 ],
 "track": "New versions, deprecation and license changes on your dashboard",
 "verdicts": [
  {
   "key": "license",
   "label": "License",
   "value": "MIT",
   "status": "yes",
   "sub": "Use it in paid apps",
   "quote": "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.",
   "note": "Keep the MIT copyright and license notice with the package files you ship.",
   "src": "https://github.com/dcastil/tailwind-merge/blob/main/LICENSE.md"
  },
  {
   "key": "maint",
   "label": "Maintained",
   "value": "Maintained",
   "status": "yes",
   "sub": "Last change Nov 22, 2026",
   "note": "Latest GitHub release Nov 19, 2026. ",
   "src": "https://github.com/dcastil/tailwind-merge"
  },
  {
   "key": "pop",
   "label": "Used by agents' projects",
   "value": "1,173 projects",
   "status": "info",
   "sub": "#2 of 53 in its category",
   "note": "Dependency in 1,173 public GitHub projects set up for AI coding agents that we scanned (18.7%).",
   "src": null
  },
  {
   "key": "agent",
   "label": "Agent access",
   "value": "Install only",
   "status": "info",
   "sub": null,
   "note": "Agent skills for this library in the skills catalog; community skills are written by others, read them before you install.",
   "src": null
  }
 ],
 "vfoot": "From the package registry and GitHub, checked daily; card checked Nov 11, 2026.",
 "blocks": [
  {
   "id": "overview",
   "nav": "Overview",
   "h2": "What Tailwind Merge does",
   "parts": [
    {
     "t": "prose",
     "text": "tailwind-merge is a small free JavaScript function for sites styled with Tailwind CSS. When a button or card gets extra style names from the page that uses it, it removes the old names that clash, so the newer style actually shows. Names it does not know stay as they are."
    },
    {
     "t": "h3",
     "text": "What people build with it"
    },
    {
     "t": "uses",
     "items": [
      {
       "title": "Change one button's look on one screen",
       "text": "Your shared Button has dark colors and small padding; on the pricing page you pass a bigger, purple version, and that one shows instead of being ignored.",
       "idea": false
      },
      {
       "title": "Components layered several levels deep",
       "text": "In a design system where a menu item wraps a base option, each level can tweak the style and the last tweak wins.",
       "idea": false
      },
      {
       "title": "A red one-off without a new variant",
       "text": "One delete button needs a red background; you pass the red style once instead of teaching the Button a new \"danger\" mode you may drop later.",
       "idea": false
      },
      {
       "title": "Teach it your own size scale",
       "text": "Your theme adds shadow sizes 100, 200 and 300; you tell tailwind-merge about them so a later shadow replaces an earlier one.",
       "idea": false
      },
      {
       "title": "Red border on a form field with an error",
       "text": "A sign-up form swaps the gray border for a red one only while the email is wrong, without both colors fighting.",
       "idea": true
      },
      {
       "title": "Clean up style names an AI assistant wrote",
       "text": "Generated components often stack clashing spacing or color names; passing them through the function leaves only the ones that take effect.",
       "idea": true
      }
     ]
    }
   ]
  },
  {
   "id": "popularity",
   "nav": "Popularity",
   "h2": "Tailwind Merge popularity",
   "parts": [
    {
     "t": "stats",
     "items": [
      {
       "n": "80",
       "of": "/ 100",
       "l": "Gid Score, #105 overall"
      },
      {
       "n": "118M",
       "l": "downloads a week, npm"
      },
      {
       "n": "5,704",
       "l": "GitHub stars"
      },
      {
       "n": "1,173",
       "l": "agent projects use it"
      }
     ]
    },
    {
     "t": "small",
     "text": "Gid Score measures public popularity and activity, not quality.",
     "link": "How the Gid Score is calculated",
     "path": "tools/top/"
    }
   ]
  },
  {
   "id": "usage",
   "nav": "How it is used",
   "h2": "How Tailwind Merge is used",
   "parts": [
    {
     "t": "list",
     "items": [
      "Tailwind Merge is a dependency in 1,173 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (24.1% of the 4,867 JavaScript/TypeScript ones), #2 of 53 in styling and css.",
      "Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 4,370; those are left out of every share on this page.",
      "Projects that use it most often also use clsx (98.0%), Lucide React (86.6%), Class Variance Authority (85.5%).",
      "It is more common in projects set up for Roo Code (29.7%) than for OpenAI Codex (15.8%)."
     ]
    },
    {
     "t": "h3",
     "text": "By coding agent"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "606 projects, 18.5%",
       "v": "Claude Code",
       "path": "agents/claude-code/"
      },
      {
       "l": "593 projects, 24.3%",
       "v": "Cursor",
       "path": "agents/cursor/"
      },
      {
       "l": "534 projects, 17.6%",
       "v": "GitHub Copilot",
       "path": "agents/github-copilot/"
      },
      {
       "l": "101 projects, 21.3%",
       "v": "Gemini CLI",
       "path": "agents/gemini-cli/"
      },
      {
       "l": "74 projects, 15.8%",
       "v": "OpenAI Codex",
       "path": "agents/openai-codex/"
      },
      {
       "l": "71 projects, 25.4%",
       "v": "Devin Desktop",
       "path": "agents/devin-desktop/"
      },
      {
       "l": "65 projects, 19.0%",
       "v": "OpenCode",
       "path": "agents/opencode/"
      },
      {
       "l": "33 projects, 29.7%",
       "v": "Roo Code",
       "path": "agents/roo-code/"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Often used with"
    },
    {
     "t": "rows",
     "rows": [
      {
       "l": "In 98.0% of its projects",
       "v": "clsx",
       "path": "tools/clsx/"
      },
      {
       "l": "In 86.6% of its projects",
       "v": "Lucide React",
       "path": "tools/lucide-react/"
      },
      {
       "l": "In 85.5% of its projects",
       "v": "Class Variance Authority",
       "path": "tools/class-variance-authority/"
      },
      {
       "l": "In 98.8% of its projects",
       "v": "Tailwind CSS",
       "path": "tools/tailwindcss/"
      },
      {
       "l": "In 93.3% of its projects",
       "v": "React",
       "path": "tools/react/"
      },
      {
       "l": "In 66.4% of its projects",
       "v": "Radix UI",
       "path": "tools/radix-ui/"
      },
      {
       "l": "In 63.1% of its projects",
       "v": "Next.js",
       "path": "tools/next/"
      },
      {
       "l": "In 47.5% of its projects",
       "v": "Sonner",
       "path": "tools/sonner/"
      }
     ]
    }
   ]
  },
  {
   "id": "more",
   "nav": null,
   "spy_as": "usage",
   "h2": "More about Tailwind Merge",
   "parts": [
    {
     "t": "more",
     "items": [
      {
       "title": "Funding",
       "path": "tools/funding/",
       "items": [
        "GitHub Sponsors: https://github.com/dcastil",
        "7 GitHub sponsors"
       ]
      },
      {
       "title": "More in Styling and CSS",
       "path": "tools/styling/",
       "items": [
        {
         "text": "Tailwind CSS",
         "path": "tools/tailwindcss/"
        },
        {
         "text": "Emotion",
         "path": "tools/emotion/"
        },
        {
         "text": "Sass",
         "path": "tools/sass/"
        },
        {
         "text": "tailwind-variants",
         "path": "tools/tailwind-variants/"
        },
        {
         "text": "Fontsource Inter",
         "path": "tools/fontsource-variable-inter/"
        },
        {
         "text": "NativeWind",
         "path": "tools/nativewind/"
        },
        {
         "text": "postcss-import",
         "path": "tools/postcss-import/"
        },
        {
         "text": "Lightning CSS",
         "path": "tools/lightningcss/"
        }
       ]
      }
     ]
    }
   ]
  },
  {
   "id": "alternatives",
   "nav": "Alternatives",
   "h2": "Alternatives",
   "parts": [
    {
     "t": "alts",
     "items": [
      {
       "name": "Tailwind Merge",
       "me": true,
       "facts": [
        "MIT",
        "Gid 80",
        "118M/wk"
       ]
      },
      {
       "name": "clsx",
       "why": "Pick clsx when you only need to switch class names on and off by condition and nothing from outside overrides them.",
       "path": "tools/clsx/",
       "facts": []
      },
      {
       "name": "Class Variance Authority",
       "why": "Pick Class Variance Authority to give a component named variants (primary, danger, small) instead of free-form overrides.",
       "path": "tools/class-variance-authority/",
       "facts": []
      },
      {
       "name": "tailwind-variants",
       "why": "Pick tailwind-variants when you want variants and conflict merging in one call for Tailwind components.",
       "path": "tools/tailwind-variants/",
       "facts": []
      }
     ],
     "more": "Compare Tailwind Merge with another tool",
     "more_path": "tools/compare/"
    }
   ]
  },
  {
   "id": "start",
   "nav": "Get started",
   "h2": "Get started",
   "parts": [
    {
     "t": "prompt",
     "text": "Use the npm package tailwind-merge (pin tailwind-merge@3.7.0, for Tailwind CSS v4) so every component builds its className as twMerge(defaultClasses, props.className), and use twJoin where no override is possible."
    },
    {
     "t": "steps",
     "items": [
      {
       "text": "Add the package to your project with the package manager you already use.",
       "code": "npm add tailwind-merge\nyarn add tailwind-merge\npnpm add tailwind-merge\nbun add tailwind-merge\ndeno add tailwind-merge\n",
       "src": "https://github.com/dcastil/tailwind-merge/blob/tailwind-merge@3.7.0/packages/tailwind-merge/docs/configuration.md"
      },
      {
       "text": "With a standard Tailwind setup, import twMerge and call it with the component's own classes first and the passed-in classes last.",
       "code": "import { twMerge } from 'tailwind-merge'\n\ntwMerge('px-2 py-1 bg-red hover:bg-dark-red', 'p-3 bg-[#B91C1C]')\n// → 'hover:bg-dark-red p-3 bg-[#B91C1C]'\n",
       "src": "https://github.com/dcastil/tailwind-merge/blob/tailwind-merge@3.7.0/packages/tailwind-merge/docs/configuration.md"
      }
     ]
    },
    {
     "t": "h3",
     "text": "Mistakes to avoid"
    },
    {
     "t": "mistakes",
     "items": [
      {
       "dont": "Installing tailwind-merge 3.x in a project on Tailwind CSS v3",
       "fix": "Check the tailwindcss version first; on v3 pin tailwind-merge@2.6.0, on v4 use 3.x",
       "why": "Version 3.0.0 dropped Tailwind CSS v3 support, changed theme keys and removed the isLength validator."
      },
      {
       "dont": "twMerge('p-2', { 'p-4': isBig })",
       "fix": "twMerge(clsx('p-2', { 'p-4': isBig })) or twMerge('p-2', isBig && 'p-4')",
       "why": "twMerge takes strings, arrays and falsy values only; in our run the object was dropped and the result was 'p-2'."
      },
      {
       "dont": "Calling extendTailwindMerge({...}) inside a component or render function",
       "fix": "Create the custom function once at module level and import it everywhere",
       "why": "Building the merge function computes a large data structure each time it is called."
      },
      {
       "dont": "Mixing an arbitrary property like [padding:1rem] with p-4 and expecting one to replace the other",
       "fix": "Use standard Tailwind classes (p-4 p-8) when they must override each other",
       "why": "Arbitrary properties do not conflict with matching Tailwind classes; our run returned 'p-4 [padding:1rem]'."
      },
      {
       "dont": "font-(--my-family) font-(--my-weight) for a font family set by a variable",
       "fix": "font-(family-name:--my-family) font-(--my-weight)",
       "why": "Unlabeled font variables count as font weight, so the family class is removed; our run returned 'font-(--my-weight)'."
      }
     ]
    }
   ]
  },
  {
   "id": "faq",
   "nav": "Questions",
   "h2": "Questions",
   "parts": [
    {
     "t": "faq",
     "items": [
      {
       "q": "Does the order of the arguments matter?",
       "a": "Yes. When two classes clash, the later one wins, so put the component's own classes first and the passed-in ones last.",
       "evidence": {
        "url": "https://github.com/dcastil/tailwind-merge/blob/tailwind-merge@3.7.0/packages/tailwind-merge/docs/features.md",
        "quote": "twMerge('p-5 p-2 p-4') // → 'p-4'"
       }
      },
      {
       "q": "Can I pass conditions like with clsx?",
       "a": "Yes for strings, arrays and false, null or undefined values. Objects such as { 'p-4': isBig } are not supported; in our run twMerge ignored the object.",
       "evidence": {
        "url": "https://github.com/dcastil/tailwind-merge/blob/tailwind-merge@3.7.0/packages/tailwind-merge/docs/features.md",
        "quote": "twMerge('my-class', false && 'not-this', null && 'also-not-this', true && 'but-this')"
       }
      },
      {
       "q": "Will calling it on every render slow my app down?",
       "a": "Usually not. Results are cached, up to 500 different results by default.",
       "evidence": {
        "url": "https://github.com/dcastil/tailwind-merge/blob/tailwind-merge@3.7.0/packages/tailwind-merge/docs/features.md",
        "quote": "The library uses a computationally lightweight LRU cache which stores up to 500 different results by default."
       }
      },
      {
       "q": "What if my classes never clash?",
       "a": "Use twJoin from the same package. It only joins strings, which is faster and easier to reason about.",
       "evidence": {
        "url": "https://github.com/dcastil/tailwind-merge/blob/tailwind-merge@3.7.0/packages/tailwind-merge/docs/when-and-how-to-use-it.md",
        "quote": "If you want to merge classes that are all defined within a component, prefer using the twJoin function over twMerge."
       }
      },
      {
       "q": "Does it handle hover and other prefixes?",
       "a": "Yes. hover:p-2 and hover:p-4 clash, but p-2 and hover:p-4 are kept together.",
       "evidence": {
        "url": "https://github.com/dcastil/tailwind-merge/blob/tailwind-merge@3.7.0/packages/tailwind-merge/docs/features.md",
        "quote": "twMerge('hover:p-2 hover:p-4') // → 'hover:p-4'"
       }
      }
     ]
    }
   ]
  }
 ],
 "glance": [
  [
   "Package",
   "npm tailwind-merge"
  ],
  [
   "Category",
   "Styling and CSS"
  ],
  [
   "License",
   "MIT"
  ],
  [
   "Gid Score",
   "79.9"
  ],
  [
   "Rank in category",
   "#2 of 53"
  ],
  [
   "GitHub",
   "dcastil/tailwind-merge"
  ],
  [
   "Last change",
   "Nov 22, 2026"
  ]
 ],
 "good": [
  "Version 3 works with Tailwind CSS 4.0 to 4.3 only. A project still on Tailwind 3 needs tailwind-merge 2.6.0.",
  "It adds about 7 kB to the page, mostly a built-in list of which Tailwind names clash.",
  "It does not read your own style sheet. A custom name that sets padding is kept next to Tailwind padding names."
 ],
 "checked_line": "Read by AgentGid from 12 official pages, card checked Nov 11, 2026; numbers update daily.",
 "logo": "https://agentgid.com/media/avatars/dcastil.png"
}