PHPackages                             wrux/craft-cva - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wrux/craft-cva

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

wrux/craft-cva
==============

Class Variance Authority port for CraftCMS.

0.0.2(1y ago)5231[2 issues](https://github.com/wrux/craft-cva/issues)mitPHPPHP &gt;=8.2.0CI failing

Since Mar 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/wrux/craft-cva)[ Packagist](https://packagist.org/packages/wrux/craft-cva)[ RSS](/packages/wrux-craft-cva/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

[![Craft Class Variance Authority](resources/img/cva.png)](resources/img/cva.png)

Craft Class Variance Authority
==============================

[](#craft-class-variance-authority)

Class Variance Authority plugin for CraftCMS.

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 4.8.0 or later, and PHP 8.1.0 or later.

Installation
------------

[](#installation)

You can install this plugin from the Plugin Store or with Composer.

#### From the Plugin Store

[](#from-the-plugin-store)

Go to the Plugin Store in your project’s Control Panel and search for “cva”. Then press “Install”.

#### With Composer

[](#with-composer)

Open your terminal and run the following commands:

```
# go to the project directory
cd /path/to/my-project.test

# tell Composer to load the plugin
composer require wrux/craft-cva

# tell Craft to install the plugin
./craft plugin/install craft-cva
```

Usage
-----

[](#usage)

This plugin provides utility functions for generating HTML class names and component variants.

### CX

[](#cx)

The `cx` function is a utility for generating class names. It's inspired by the [clsx](https://github.com/lukeed/clsx) JavaScript package.

```
{# Generate a single class name #}
{{ cx('text-red-500') }}
{# Output: `text-red-500` #}

{# Generate multiple class names #}
{{ cx('text-red-500', 'bg-blue-500') }}
{# Output: `text-red-500 bg-blue-500` #}

{# Generate class names based on a condition #}
{{ cx('text-red-500', 'bg-blue-500', { 'text-lg': true, 'text-sm': false }) }}
{# Output: `text-red-500 bg-blue-500 text-lg` #}
```

### CVA

[](#cva)

The `cva` function is a utility for generating component variants. It's inspired by the [class-variance-authority](https://cva.style/) JavaScript package.

```
{# Create the component configuration #}
{% set button = cva('block outline-none', {
  variants: {
    display: {
      primary: [
        'bg-blue-500 text-white',
      ],
      secondary: [
        'bg-purple-500 text-white',
      ],
    },
    size: {
      base: [
        'py-2 px-4 text-base',
      ],
      large: [
        'py-3 p-6 text-lg',
      ],
    },
  },
  defaultVariants: {
    display: 'primary',
    size: 'base',
  },
}) %}

{# Generate various button variants #}

  Click me

{#
Output:

  Click me

#}

  Click me

{#
Output:

  Click me

#}

  Click me

{#
Output:

  Click me

#}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance40

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~410 days

Total

2

Last Release

383d ago

PHP version history (2 changes)0.0.1PHP &gt;=8.1.0

0.0.2PHP &gt;=8.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1bcd65a1afd6de38b2664d87163305c4574205c5ac1676514279cda8eea4cd2a?d=identicon)[wrux](/maintainers/wrux)

---

Top Contributors

[![wrux](https://avatars.githubusercontent.com/u/1453384?v=4)](https://github.com/wrux "wrux (5 commits)")[![ishetnogferre](https://avatars.githubusercontent.com/u/6649706?v=4)](https://github.com/ishetnogferre "ishetnogferre (1 commits)")

---

Tags

cmsCraftcraftcmscraft-plugin

### Embed Badge

![Health badge](/badges/wrux-craft-cva/health.svg)

```
[![Health](https://phpackages.com/badges/wrux-craft-cva/health.svg)](https://phpackages.com/packages/wrux-craft-cva)
```

###  Alternatives

[verbb/navigation

Create navigation menus for your site.

90683.7k17](/packages/verbb-navigation)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[verbb/tablemaker

Create customizable and user-defined table fields.

40168.8k1](/packages/verbb-tablemaker)[supercool/tablemaker

Create customizable and user-defined table fields.

40141.7k](/packages/supercool-tablemaker)[pennebaker/craft-architect

CraftCMS plugin to generate content models from JSON/YAML data.

72148.5k5](/packages/pennebaker-craft-architect)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
