Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Tailwind Merge Php

Tailwind Merge Php Laravel Package

tales-from-a-dev/tailwind-merge-php

TailwindMerge for PHP is a fork of tailwind-merge that merges multiple Tailwind CSS classes and resolves conflicts by removing classes overridden by later ones. Supports Tailwind v4.0–v4.3 and PHP 8.1+, with configurable caching and settings.

View on GitHub
Deep Wiki
Context7

TailwindMerge for PHP is a PHP port of tailwind-merge that merges multiple Tailwind CSS classes and automatically resolves conflicts by removing classes overridden by a class defined later. It requires PHP 8.1+ and supports Tailwind v4.0 through v4.3, making it easy to build dynamic, conditional class strings without duplicate or conflicting utilities.

  • Conflict-aware merging of Tailwind utility classes
  • Full support for Tailwind v4.0–v4.3
  • Configurable class groups and custom mappings
  • Optional caching for improved performance
  • Framework-agnostic and easy to install via Composer

Detailed documentation covering prerequisites, installation, usage, cache, and configuration lives in the docs directory.

Frequently asked questions about Tailwind Merge Php
How do I install TailwindMerge for PHP in a Laravel app?
Install it with Composer using composer require tales-from-a-dev/tailwind-merge-php. The package requires PHP 8.1 or newer and does not require a Laravel service provider. After installation, use the documented merger class or call it from Blade, Livewire, or a helper.
Does TailwindMerge for PHP work with Laravel 10 and Laravel 11?
It is framework-agnostic, so any Laravel version running on PHP 8.1 or newer can use it. There is no service provider or Laravel-specific coupling. Laravel 10 and 11 typically qualify as long as your application meets the PHP requirement.
How is TailwindMerge different from Laravel's $attributes->merge()?
Laravel's $attributes->merge() concatenates class values but does not resolve Tailwind utility conflicts. TailwindMerge removes earlier classes that are overridden by later ones, so the two tools compose rather than compete. Use $attributes->merge() for attribute bags and TailwindMerge for conflict-aware class lists.
Which Tailwind CSS versions are supported by this package?
It supports Tailwind v4.0 through v4.3. The package is a PHP port pinned to an upstream tailwind-merge version, so utilities added in later Tailwind minors may pass through unmerged until the pin moves. Check the changelog and fixture tests for exact parity.
How do I merge Tailwind classes inside a Blade component?
Build the complete class string in PHP and pass it through the merger before rendering. In Blade, call it from a component class, view composer, or helper instead of relying only on $attributes->merge(). This keeps conditional and override classes predictable.
Can I cache Tailwind class merging for better performance?
Yes, optional caching is documented for the package. Caching helps when the same class lists are merged repeatedly, such as in loops or high-traffic views. Measure first, because the precompiled default class map may be fast enough for simple one-off merges.
What alternatives exist to TailwindMerge for PHP?
The original gehrisandro/tailwind-merge-php is the upstream PHP port that this package forks. You can also avoid runtime merging by manually controlling class order, but that becomes error-prone with conditional Tailwind classes. This fork's main distinction is support for Tailwind v4.0 through v4.3 on PHP 8.1+.
How do I configure custom Tailwind classes or prefixes?
Configuration options are available for custom needs such as class groups and conflicting class groups. Because the default class map is precompiled, confirm how custom configuration layers on top and test representative classes. Pin the package version when relying on custom behavior.
Is TailwindMerge for PHP safe to use in production?
It is pre-1.0 and maintained by a single maintainer as a fork, so pin exact versions and review upgrade notes. The package is small and framework-agnostic, which limits integration risk. Production use should include tests for your critical class merges and a plan for Tailwind version updates.
How should I test Tailwind class merging in my Laravel application?
Test representative Tailwind class combinations that matter to your UI, especially conditional and override cases. The package's own fixture suite is the authoritative parity record, so mirror key cases in your app tests. Rerun tests after package upgrades because pre-1.0 minor releases can change behavior.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo