Install
Works with Drupal: ^10.3 || ^11 || ^12Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
New: the tw_merge filter
Merge classes with the new tw_merge Twig filter. It follows its input, so there is no option to set:
{{ 'p-4 bg-white p-2'|tw_merge }}outputsbg-white p-2{{ ['p-4', 'bg-white', 'p-2']|tw_merge }}outputsbg-white p-2{{ attributes.addClass(['p-4', 'bg-white', 'p-2']|tw_merge).removeClass('p-2') }}outputsclass="bg-white"
Legacy functions still work
The tw_merge() and tw_merge_as_array() functions, including the as='string' and as='array' options, were not removed. Existing templates keep working without changes. They are described in LEGACY.md, with their filter equivalents.
Prefix
- Enter the prefix as in
prefix(tw), for exampletw, for classes liketw:flex. - Spaces, a trailing colon and capital letters are fixed automatically when you save.
tw:,twandTWare all saved astw. - Like Tailwind CSS 4.x, only letters (a-z) are accepted. Anything else, such as
tw-, shows an error and is not saved.
Library update
Now requires tales-from-a-dev/tailwind-merge-php ^0.5.0. It sets up faster and uses less memory. A few utilities now merge differently, matching tailwind-merge 3.7.0:
outline-2andoutlinenow conflict.opacity-50andopacity-(--o)now conflict.delay-100anddelay-initialno longer conflict.skew-*no longer uses the spacing theme.
Other improvements
- Faster: the merge library is created once, only when a page first merges classes.
- Saving the prefix clears all rendered output, so the new prefix applies right away.
- Kernel and functional tests cover the filter, the legacy functions, the prefix and the settings page.
API change for custom code
The Drupal\tailwind_merge_classes\Service\TailwindMergeService class and the tailwind_merge_classes.tailwind_merge_service service were removed. Custom code should use the Drupal\tailwind_merge_classes\TailwindMergeInterface service instead. Twig templates are not affected.