Drupal is a registered trademark of Dries Buytaert
cms 2.1.3 Update released for Drupal core (2.1.3)! drupal 10.5.11 Update released for Drupal core (10.5.11)! drupal 11.3.11 Update released for Drupal core (11.3.11)! drupal 11.2.13 Update released for Drupal core (11.2.13)! drupal 10.6.10 Update released for Drupal core (10.6.10)! cms 2.1.2 Update released for Drupal core (2.1.2)! drupal 11.1.10 Update released for Drupal core (11.1.10)! drupal 10.5.10 Update released for Drupal core (10.5.10)! drupal 10.4.10 Update released for Drupal core (10.4.10)! drupal 11.2.12 Update released for Drupal core (11.2.12)! drupal 11.3.10 Update released for Drupal core (11.3.10)! drupal 10.6.9 Update released for Drupal core (10.6.9)! drupal 10.6.8 Update released for Drupal core (10.6.8)! drupal 11.3.9 Update released for Drupal core (11.3.9)! drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)!

Introduction

Tailwind Merge Classes is a Drupal module for users working with Tailwind CSS in a component-based syntax. It provides a Twig extension that merges multiple Tailwind CSS classes, resolves conflicts automatically, and ensures a clean, optimized class list. For example, tw_merge(['p-2', 'p-4']) intelligently keeps only the last one, 'p-4'. Array output is also supported via tw_merge with as='array' (or the legacy tw_merge_as_array function), which is recommended when used with Drupal's addClass(). If you are interested in more details, this video explains the original JavaScript utility tailwind-merge that this module's logic is based on.

Usage

Get started quickly by checking out dedicated guides:

Version Support

  • Module version 1.x: Compatible only with Tailwind CSS 3.x
  • Module version 2.x: Compatible only with Tailwind CSS 4.x

Post-Installation

Once you install the Tailwind Merge Classes module, there's no need for extra configuration or managing content types. Simply enable the module and start using it in your Twig files.

Third-Party Libraries

This module depends on different PHP packages to handle merging of Tailwind CSS classes for each Tailwind version.

Both PHP packages require PHP 8.1 and above.

Activity

Total releases
10
First release
Jan 2025
Latest release
1 week ago
Release cadence
54 days
Stability
70% stable

Release Timeline

Releases

Version Type Release date
2.2.0 Stable May 24, 2026
1.2.0 Stable May 24, 2026
2.1.0 Stable Jan 18, 2026
1.1.0 Stable Jan 18, 2026
2.0.0 Stable Dec 31, 2025
1.0.1 Stable Dec 28, 2025
1.0.0 Stable Dec 27, 2025
1.0.0-beta2 Pre-release Jun 19, 2025
1.0.0-beta1 Pre-release Jan 22, 2025
1.0.x-dev Dev Jan 20, 2025