Skip to main content

Duck Variants

Type-safe variant system with cva(). Compound variants, default variants, and a VariantProps helper, all inferred from your config.

Type-safe cva()

Variant systems with full type inference

A cva-compatible variant authoring tool. Defaults, compound variants, and a typed `VariantProps` helper. No build step, no runtime surprises.

Type-safe variants

Every variant, default, and compound is inferred. `VariantProps<typeof button>` returns the union of legal props.

Variant-driven styles

Define variants once, reuse them everywhere. `intent`, `size`, `tone`, whatever your design system needs.

Default variants

Declare defaults so consumers rarely have to spell them out. Override per instance when you need to.

Compound variants

Add extra classes when multiple variants match. Handy for `primary + lg` accents or `outline + destructive` combos.

Zero dependencies

Works with Tailwind, but not tied to it. Use it with any className-based styling solution.

cva-compatible

API-compatible with class-variance-authority. Migrate an existing codebase by changing the import.

Install

Author variants, export the types.

# Install
bun add @gentleduck/variants

# Author a variant system
import { cva, type VariantProps } from '@gentleduck/variants'

Free & open source

gentleduck is MIT licensed and will always be free and open source. Every package ships with full source access — fork it, modify it, own it.

Become a Sponsor