Skip to content

Other Use Cases

This content is for Beta. Switch to the latest version for up-to-date documentation.

Although primarily designed for handling class names, at its core cva is a fancy way of managing a string…

import { cva } from "cva";
const greeter = cva({
base: "Good morning!",
variants: {
isLoggedIn: {
true: "Here's a secret only logged in users can see",
false: "Log in to find out more…",
},
},
defaultVariants: {
isLoggedIn: "false",
},
});
greeter();
// => "Good morning! Log in to find out more…"
greeter({ isLoggedIn: "true" });
// => "Good morning! Here's a secret only logged in users can see"