Download the PHP package tobimori/kirby-tailwind-merge without Composer

On this page you can find all versions of the php package tobimori/kirby-tailwind-merge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package kirby-tailwind-merge

Kirby Tailwind Merge

Intelligently merge Tailwind classes without style conflicts in your Kirby templates.

This plugin relies on tailwind-merge-php by Sandro Gehri for merging classes and only adapts it to work in the "Kirby ecosystem". Any issues related to merging classes should probably reported over there.

Installation

Manual installation

Download and copy this repository to /site/plugins/kirby-tailwind-merge, or apply this repository as Git submodule.

Usage

This plugin provides two helper functions to use in your blueprints. Whether functions should be registered can be controlled in your config.php, see Options.

attr()

This helper function works similar to the Kirby built-in attr() function and overwrites it to support Tailwind Merge behaviour for the class attribute.

You'll need to disable the built-in attr() helper at the top-most location in your index.php file - before Kirby is loaded.

Example

merge()

merge() applies Tailwind Merge behaviour and outputs a class attribute.

Example

cls()

cls() applies Tailwind Merge behaviour and outputs the contents of class attribute. This can be used to work better with the conditional merge syntax this plugin provides, and also for nesting.

Example

Conditional merging

This conditional merge syntax using arrays can be used with the merge() and attr() functions as well.

mod($modifier, $classes)

mod() applies the specified modifier/variant to each class supplied in the $class string. It also applies Tailwind Merge behaviour and outputs the contents of class attribute. This is useful when you have a bunch of classes and want them all to activate at the same modifier.

Example

"But Tailwind won't parse my classes then!"

I hear you, but thankfully Tailwind allows us to customize the parser to our needs. This is not a 100% perfect technique due to being reliant on regexing' the classes, but it works for most cases.

With a custom transformer function to scan for the mod() function, your tailwind.config.js could look like this:

For simplicity in parsing the function with Tailwind, the mod() function doesn't support arrays. With this approach, you're also not aple to e.g. use a variable inside the function, but only direct strings.

If you still want to use variables, that e.g. come from the CMS directly, you can add the generated classes to your safelist and they'll be generated to matter what.

Options

Option Default Description
prefix `` Set a prefix for your tailwind classes

Options allow you to fine tune the behaviour of the plugin. You can set them in your config.php file:

Support

This plugin is provided free of charge & published under the permissive MIT License. If you use it in a commercial project, please consider to sponsor me on GitHub to support further development and continued maintenance of my plugins.

License

MIT License Copyright © 2023 Tobias Möritz


All versions of kirby-tailwind-merge with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2.0
getkirby/composer-installer Version ^1.2
gehrisandro/tailwind-merge-php Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tobimori/kirby-tailwind-merge contains the following files

Loading the files please wait ....