awesome-repositories.com
Blog
awesome-repositories.com

Discover the best open-source repositories with AI-powered search.

ExploreCurated searchesOpen-source alternativesSelf-hosted softwareBlogSitemap
ProjectAboutHow we rankPressMCP server
LegalPrivacyTerms
© 2026 Bringes Technology SRL·VAT RO45896025·hello@awesome-repositories.com
·
dcastil avatar

dcastil/tailwind-merge

0
View on GitHub↗
5,648 stars·97 forks·TypeScript·MIT·5 viewsnpmjs.com/package/tailwind-merge↗

Tailwind Merge

tailwind-merge is a utility library that resolves conflicting Tailwind CSS class strings when combining multiple sets of classes. It automatically detects and removes conflicting utility classes, keeping only the last class from each group that modifies the same CSS property, while preserving non-conflicting and non-Tailwind classes unchanged.

The library handles complex conflict scenarios including modifier-order resolution, arbitrary value type detection, postfix modifier semantics, and asymmetric conflicts where one class group removes preceding classes from other groups but not vice versa. It supports third-party Tailwind plugins through extensible configuration, allowing custom class groups, conflict rules, and validators to be merged into the default setup. Users can build fully custom merge functions from scratch or extend the default configuration with overrides and additions.

Performance is optimized through deferred initialization that delays expensive setup until the first merge call, internal data structure reuse across calls, and an LRU cache that stores recent merge results to skip redundant computation on repeated inputs. The library also provides conditional class joining without conflict resolution as a lightweight alternative for internal component styles.

Features

  • Arbitrary Value Class Mergers - Merges classes with arbitrary values, automatically detecting their type and resolving conflicts.
  • Tailwind CSS Conflict Resolvers - Resolves conflicting Tailwind utility classes by keeping only the last class from each group that modifies the same CSS property.
  • Modifier Conflict Resolvers - Resolves conflicts between classes with modifiers, including stacked modifiers, respecting modifier order rules.
  • Modifier-Order Conflict Resolvers - Resolves conflicts between classes with stacked modifiers by respecting Tailwind's modifier order rules.
  • Tailwind Class - Merges multiple Tailwind CSS class strings into a single string, handling conditional values and nested arrays without style conflicts.
  • CSS Arbitrary Value Type Detectors - Provides heuristics to infer CSS types from arbitrary bracket values, enabling correct conflict resolution.
  • Class String Joiners - Provides a utility that accepts multiple arguments, conditional values, and nested arrays to build a single merged class string.
  • Shorthand Conflict Resolvers - Handles complex conflicts like between shorthand and longhand properties or opposite display values.
  • Prop-Based Utility Styling - Provides a utility that applies arbitrary Tailwind utilities via className props, eliminating the need for explicit style props.
  • Component Style Overrides - Enables overriding component styles through className props instead of defining every styling option as a prop.
  • Arbitrary CSS Property Mergers - Merges classes with arbitrary CSS properties while acknowledging limitations in conflict resolution.
  • Ambiguous Arbitrary Value Disambiguators - Uses explicit labels to disambiguate arbitrary value classes that match multiple Tailwind patterns.
  • Custom Merge Function Builders - Allows building a fully custom merge function from scratch to tree-shake default configurations.
  • Asymmetric Conflict Definitions - Sets up one-way conflicts where a class group removes preceding classes from other groups but not vice versa.
  • Custom Class Group Configurations - Allows users to define custom groups of conflicting Tailwind classes for the merge function.
  • Non-Conflicting Refinement Preservers - Preserves multiple classes that refine the same property without conflict during merging.
  • Non-Tailwind Class Preservers - Keeps any class that is not a Tailwind utility class unchanged during merging.
  • Merge Configuration Overrides - Creates custom merge functions by extending or overriding the default Tailwind configuration with custom theme values and class groups.
  • Default Merge Configuration Extenders - Creates custom merge functions by extending the default Tailwind configuration with overrides and additions.
  • Tailwind Merge Configuration Extenders - Provides an API to extend the default merge configuration with custom theme values and class groups.
  • Tailwind Plugin Integrations - Supports third-party Tailwind plugins through extensible configuration, allowing custom class groups and conflict rules to be merged.
  • CSS Class Value Validators - Provides validator functions to check if a class value matches a specific CSS type for correct conflict resolution.
  • Merge Configuration Extensions - Allows extending the default merge configuration with custom class groups, theme values, and conflict rules for third-party plugins.
  • Merge Plugin Integrations - Extends the merge function to support third-party Tailwind CSS plugin classes by adding custom class groups and conflict rules.
  • Non-Tailwind Class Preservers - Preserves any class that is not a Tailwind utility class unchanged during merging.
  • Conflict-Free Joiners - Provides a conflict-free class joining mode as a lightweight alternative to the full conflict resolver.
  • Arbitrary Variant Class Mergers - Merges classes with arbitrary variants while acknowledging limitations in conflict resolution.
  • Third-Party Plugin Class Mergers - Integrates third-party Tailwind plugin classes into the merge function by adding custom class groups.
  • Conditional Joining - Ships a lightweight conditional class joining utility as an alternative to clsx for internal component styles.
  • Multi-Level Style Override Passers - Passes style overrides through nested component layers without breaking existing styles.
  • One-Way Conflict Definitions - Ships configuration for one-way class group conflicts, enabling precise asymmetric override rules.
  • Tailwind Merge Configuration Builders - Builds a merge function from scratch with full control over class groups, conflicts, and modifiers.

Star history

Star history chart for dcastil/tailwind-mergeStar history chart for dcastil/tailwind-merge

AI search

Explore more awesome repositories

Describe what you need in plain English — the AI ranks thousands of curated open-source projects by relevance.

Start searching with AI

Curated searches featuring Tailwind Merge

Hand-picked collections where Tailwind Merge appears.
  • Tailwind CSS Plugin Ecosystem

Open-source alternatives to Tailwind Merge

Similar open-source projects, ranked by how many features they share with Tailwind Merge.
  • joe-bell/cvajoe-bell avatar

    joe-bell/cva

    6,849View on GitHub↗

    cva is a TypeScript utility for defining and resolving visual variants for UI components with full type safety. It generates CSS class strings from typed variant definitions, enabling compile-time validation of component usage by deriving the union of all variant prop types from a configuration object. The library distinguishes itself through compound variant matching, which activates styles only when multiple independent variant conditions are simultaneously satisfied, merging their class names. It also provides default value propagation to ensure consistent rendering when no explicit varian

    TypeScriptclass-variance-authorityclassnameclassnames
    View on GitHub↗6,849
  • jedwatson/classnamesJedWatson avatar

    JedWatson/classnames

    17,794View on GitHub↗

    classnames is a JavaScript utility for conditionally joining CSS class names into a single space-separated string. It functions as a class name manager that maps boolean flags and objects to specific styles for HTML attribute assignment. The tool resolves abstract class identifiers to computed values, facilitating integration with modular styling systems. It allows for the mapping of dynamic identifiers to scoped class names through a dedicated module resolver. The utility processes strings, arrays, and objects to handle dynamic class name management. It includes capabilities for recursive a

    JavaScript
    View on GitHub↗17,794
  • ben-rogerson/twin.macroben-rogerson avatar

    ben-rogerson/twin.macro

    8,030View on GitHub↗

    twin.macro is a build-time style compiler and utility-first styling tool that converts Tailwind CSS utility classes into optimized style objects for JavaScript styling libraries. It acts as an integration bridge, allowing developers to use Tailwind design tokens and utility classes within a component-based architecture. The project distinguishes itself by performing transformations during the compilation phase rather than at runtime. It maps utility strings to CSS-in-JS engines such as Emotion and Styled Components, resolving design tokens directly from a Tailwind configuration file to ensure

    TypeScriptbabelbabel-macrocss-in-js
    View on GitHub↗8,030
  • styled-system/styled-systemstyled-system avatar

    styled-system/styled-system

    7,870View on GitHub↗

    Styled System is a JavaScript library that provides a style props approach for building UI components, enabling developers to map CSS properties directly to component props for rapid, declarative development. At its core, it resolves design tokens from a centralized theme object into CSS values, ensuring consistent styling across components without writing custom stylesheets. The library supports theme-aware styling that connects component styles to a theme object for scalable, maintainable design systems with dynamic value resolution. The library differentiates itself through several capabil

    JavaScriptcolorscsscss-in-js
    View on GitHub↗7,870
See all 30 alternatives to Tailwind Merge→

Frequently asked questions

What does dcastil/tailwind-merge do?

tailwind-merge is a utility library that resolves conflicting Tailwind CSS class strings when combining multiple sets of classes. It automatically detects and removes conflicting utility classes, keeping only the last class from each group that modifies the same CSS property, while preserving non-conflicting and non-Tailwind classes unchanged.

What are the main features of dcastil/tailwind-merge?

The main features of dcastil/tailwind-merge are: Arbitrary Value Class Mergers, Tailwind CSS Conflict Resolvers, Modifier Conflict Resolvers, Modifier-Order Conflict Resolvers, Tailwind Class, CSS Arbitrary Value Type Detectors, Class String Joiners, Shorthand Conflict Resolvers.

What are some open-source alternatives to dcastil/tailwind-merge?

Open-source alternatives to dcastil/tailwind-merge include: joe-bell/cva — cva is a TypeScript utility for defining and resolving visual variants for UI components with full type safety. It… jedwatson/classnames — classnames is a JavaScript utility for conditionally joining CSS class names into a single space-separated string. It… ben-rogerson/twin.macro — twin.macro is a build-time style compiler and utility-first styling tool that converts Tailwind CSS utility classes… styled-system/styled-system — Styled System is a JavaScript library that provides a style props approach for building UI components, enabling… geekyants/nativebase — NativeBase is a comprehensive toolkit of accessible components and responsive design frameworks used to build… chakra-ui/chakra-ui-vue — Chakra UI Vue is a component library for the Vue.js ecosystem that provides a collection of modular, accessible…