type-safe · class-variance-authority · tailwind-css

styled-cva

A typesafe, class-variance-authority-based, styled-components-like library for authoring React, Solid, Vue, and ReScript components.

import  from "@styled-cva/react";

// Intrinsic CVA shorthand with typed variant inference
export const  = .(
  "inline-flex items-center justify-center rounded-md font-medium transition-colors",
  {
    : {
      : {
        : "bg-blue-600 text-white hover:bg-blue-700",
        : "bg-slate-100 text-slate-900 hover:bg-slate-200",
      },
      : {
        : "h-8 px-3 text-xs",
        : "h-10 px-4 text-sm",
      },
    },
    : {
      : "primary",
      : "md",
    },
  },
);

// Full autocompletion on $variant and $size props:
export const  = () => (
  < ="primary" ="md">
    Click me
  </>
);

Type-Safe CVA Variants

First-class TypeScript inference for variant props, default variants, and compound variants without boilerplate.

Intrinsic CVA Shorthand

Author components directly with tw.button(base, config) — clean, concise, and familiar styled syntax.

Multi-Framework & Polymorphic

Available for React, Solid, Vue, and ReScript. Polymorphic $as prop support to easily swap elements or custom components.

Dedicated Tooling

Official ESLint, Prettier, and Biome plugins to enforce clean Tailwind class strings and auto-extract styled components.