Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Block Layout Accordion 1.0.2 Minor update available for module block_layout_accordion (1.0.2). Release: Canvas interactive toggle 1.0.2 Minor update available for module canvas_interactive_toggle (1.0.2). Release: Views HTTP Client 1.0.2 Minor update available for module views_http_client (1.0.2). Release: Block Layout Accordion 1.0.1 Minor update available for module block_layout_accordion (1.0.1). Release: Canvas interactive toggle 1.0.1 Minor update available for module canvas_interactive_toggle (1.0.1). Release: Video.js (HTML5 Video Player) 10.0.0-alpha1 First alpha version released for module videojs (10.0.0-alpha1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Release: Audit Trail 1.0.0-alpha7 New alpha version released for module audit_trail (1.0.0-alpha7). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

CVA (Class Variance Authority)

6,267 sites Security covered Drupal 11 · not 10
View on drupal.org

This module exposes Twig's `html_cva` function to Drupal templates, allowing developers to manage component variants using the Class Variance Authority (CVA) pattern. This is particularly helpful for building reusable components, especially when working with utility-first CSS frameworks like Tailwind CSS.

⚠️ Note: CVA support was added to Drupal core 11.4! If you're on 11.4 or later, you do not need this module; if you're a theme developer, you can use core's CVA support exactly as described below. This module will not be released for Drupal 12, and is no longer being worked on.

Exposes Twig's built-in html_cva function to Drupal templates, enabling Class Variance Authority (CVA) for managing component variants. Useful for building reusable components with Tailwind CSS and other utility-first frameworks. This helps manage component variants (size, color, style, etc.) in Twig templates using a CVA pattern, similar to shadcn/ui and other component libraries.

Usage Example

{% set button = html_cva(
  base: 'button',
  variants: {
    variant: { primary: 'bg-blue', secondary: 'bg-gray' },
    size: { sm: 'text-sm', md: 'text-base', lg: 'text-lg' }
  }
) %}

<button class="{{ button.apply({variant: 'primary', size: 'md'}) }}">
  Click me
</button>

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

8 tracked projects depend on this one

Activity

Tracked releases
2
Tracked since
Nov 2025
Latest release
7 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Slowing

Releases

Version Type Core Release date
1.0.0 Stable 11 Jan 21, 2026
1.0.0-beta1 Pre-release 11 Nov 20, 2025