Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

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>

Activity

Total releases
2
First release
Nov 2025
Latest release
5 months ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

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