Download the PHP package vewe/classvariance without Composer
On this page you can find all versions of the php package vewe/classvariance. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vewe/classvariance
More information about vewe/classvariance
Files in vewe/classvariance
Package classvariance
Short Description Vewe ClassVariance, an all-PHP combined implementation of Class Variance Authority, twMerge, and Tailwind-Variants
License MIT
Homepage https://github.com/iamdadmin/vewe-classvariance
Informations about the package classvariance
Vewe ClassVariance
About
Aiming to be an all-PHP combined implementation of Class Variance Authority, twMerge, and Tailwind-Variants.
Supporting the current version of PHP, less one, as a minimum requirement, to keep the package freshly maintained and utilising the latest features of PHP.
Version Strategy
Based on semantic versioning, with the following constraints
- 1.x.x releases support PHP8.4, PHP8.5
- 2.x.x releases support PHP8.5, PHP8.6
- 3.x.x releases support PHP8.6, PHP-Next (tbc)
Major point releases may introduce breaking changes, which will be in the release notes.
Minor point releases should be non-breaking changes and fixes.
Installation
You can install the package via composer:
Usage
Cv, with slots, akin to Tailwind-Variants
You can declare your classes as a single string, space delimited, or you can provided it as an array of strings, or a mix of the two methods, as suits your needs.
When using slots, always declare a 'base' slot consistently in the Cv::new definition. Unlike Tailwind-Variants, Cv does not assume which classes are meant for which slot, you must be declarative.
This is a conscious design decision, as your definition should have an immutable source of truth, instead of relying on script defaults which could change over time.
When you don't specify a slot, it defaults to returning the 'base' slot
You can use named properties or you can pass an empty array for $props.
You can also take advantage of Tailwind-Variants style declarations, for your component to have multiple sub-components.
[!TIP] Looking for a comprehensive set of components using
Cv? Take a look at vewe/ui! Ready for use with TempestPHP or adapt to anything you like.
Cv, without slots
When not using slots, simply omit them from your definitions entirely.
Equally, do not pass the slot property at all.
Merging additional class data
Whether or not you implement slots configuration, if you wish to pass additional classes to be merged one-off into a specific button, you can pass it in either class or className within $props.
Testing
Credits and Acknowledgements
A special thank you to the following, without whom this package would not exist.
Cvbegan as a heavily-modified fork of featureninja/cva by Roj Vroemen and contributors- In turn this was based on Class Variance Authority by Joe Bell
Also a thank you to the following projects, whose own ideas helped shape Cv.
- Tailwind-Variants by Junior Garcia @jrgarciadev, Tianen Pang @tianenpang and contributors
- Tailwind-merge by Romain Monteil which is based on Tailwind-merge-php by Sandro Gehri and contributors
License
The MIT License (MIT). Please see License File for more information.