Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Tailwind Merge Classes

40 sites Security covered Drupal 10–11
View on drupal.org

This module provides a Twig extension to automatically merge and optimize Tailwind CSS class lists, resolving conflicts to ensure a clean output. It can output classes as a string or an array, making it easy to use with Drupal's theming system.

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.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
13
Tracked since
Jan 2025
Latest release
1 week ago
Releases (12 mo)
10 ▲ from 3
Maintenance
Active

Release Timeline

Releases

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