New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

yieldstudio/tailwind-merge-php

Merge Tailwind CSS classes without style conflicts
77,611 49
Install
composer require yieldstudio/tailwind-merge-php
Latest Version:0.0.3
PHP:>=8.1
Older releases:10
License:MIT
Last Updated:Jul 19, 2023
Links: GitHub  ·  Packagist
Maintainer: JamesHemery

Social Card of Tailwind Merge PHP

Efficiently merge Tailwind CSS classes in PHP without style conflicts

Latest Version GitHub Workflow Status Total Downloads

This package allows you to merge multiple Tailwind CSS classes and automatically resolves conflicts between them without headaches.

tailwind-merge-php is a PHP port of the excellent tailwind-merge created by dcastil.

  • Supports Tailwind v3.0 up to v3.3
  • First-class support for Laravel

Installation

composer require yieldstudio/tailwind-merge-php

Usage

use YieldStudio\TailwindMerge\TailwindMerge;
use YieldStudio\TailwindMerge\TailwindMergeConfig;

// Singleton
$twMerge = TailwindMerge::instance();
$twMerge->merge('w-8 h-8 rounded-full rounded-lg'); // w-8 h-8 rounded-lg

// Custom instance
$twMerge = new TailwindMerge(TailwindMergeConfig::default()); // Config is optional
$twMerge->merge('w-8 h-8 rounded-full rounded-lg'); // w-8 h-8 rounded-lg

Laravel Support

You can publish the configuration file with:

php artisan vendor:publish --provider="YieldStudio\TailwindMerge\Laravel\TailwindMergeServiceProvider"

Using the tw helper

tw('w-8 h-8 rounded-full rounded-lg'); // w-8 h-8 rounded-lg

Using Blade directive

<div @tw('w-8 h-8 rounded-full rounded-lg')></div>

// will be
<div class="w-8 h-8 rounded-lg"></div>

Using Blade components

// avatar.blade.php
<div {{ $attributes->tw('w-8 h-8 rounded-full') }}></div>

// header.blade.php
<x-avatar class="rounded-lg" />

// will be
<div class="w-8 h-8 rounded-lg"></div>

Configuration & plugins

✍️ Complete documentation is being written

Unit tests

To run the tests, just run composer install and composer test.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you've found a bug regarding security please mail contact@yieldstudio.fr instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically...

1,230,163 340
marcorieser/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically...

6,488 0
goodm4ven/tailwind-merge

Resolves TailwindCSS class conflicts in between Laravel Blade component calls

1,792 1
sikessem/ui

Blade and TailwindCSS components to design faster.

2,963 2
nunomaduro/termwind

It's like Tailwind CSS, but for the console.

331,546,864 2,501

Version History

Version Released PHP Laravel License
0.0.3 >=8.1 MIT
0.0.2 >=8.1 MIT
0.0.1 >=8.1 ^10.4 MIT