定制 justbetter/laravel-blade-tailwind-merge 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

justbetter/laravel-blade-tailwind-merge

最新稳定版本:0.3.0

Composer 安装命令:

composer require justbetter/laravel-blade-tailwind-merge

包简介

Tailwind classes merging with Laravel Blade components

README 文档

README

Archived as there is a new package which solves the known issues of this package: tailwind-merge-laravel

Laravel Blade Tailwind Merge

This package adds a ->tailwind() method to the attribute bag used within Blade Components which let you overwrite classes.

Example

Let's say you've a Blade "link" component like this:

<a {{ $attributes->merge(['class' => 'flex px-5']) }}>
   {{ $slot }}
</a>

When you're using this like:

<x-button href="/" class="px-3">Home</x-button>

You end up with flex px-5 px-3 instead of flex px-3. Because Tailwind classes are sorted and px-5 is listed after px-3 our "overwrite" won't do anything.

Installation

composer require justbetter/laravel-blade-tailwind-merge

Usage

From the example above, just use tailwind('...') instead of merge(['class' => '...') or class('...') when you need this.

<a {{ $attributes->tailwind('flex px-5') }}>
   {{ $slot }}
</a>

Known issues

Currently the merging works only by checking the first part before the dash. So text-red-500 overwrites text-xl and visa versa because we only check for text-*. To fix this we need to know all Tailwind options just like tailwind-merge does. Maybe in the future... but a PR is welcome!

References

License

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

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-11