UnoCSS Variants (unocss-variants) is a first-class variant API for UnoCSS. You define a component recipe once — base styles, variants, defaults, slots, and compound rules — and call it anywhere with typed props.
It is a port of Tailwind Variants. The important difference: classes are never merged. Conflicting utilities stay in the class string; you resolve them with UnoCSS layers and the CSS cascade.
uv(options) takes one argument. There is no config object, no twMerge, no /lite build, and no responsive-variant map. Put breakpoint prefixes such as md: in the class strings yourself.Why UnoCSS Variants
One recipe, many call sites
Change color or size at the call site instead of editing long class strings.
Slots for multi-part UI
Cards, alerts, and pagination get named parts, each with its own classes and variants.
Compound rules
Apply extra classes when several variant keys match, or to several slots at once.
TypeScript-first
Infer call-site props with VariantProps. Slotted recipes return typed slot functions.
Key features
Variants
Define axes like color, size, or boolean flags such as disabled. Combine them independently.
<script setup>
import { uv } from 'unocss-variants';
const button = uv({
base: 'font-medium bg-blue-500 color-white rounded-full active:opacity-80',
variants: {
color: {
primary: 'bg-blue-500 color-white',
secondary: 'bg-purple-500 color-white'
},
size: {
sm: 'text-sm',
md: 'text-base',
lg: 'px-4 py-3 text-lg'
}
},
compoundVariants: [
{
size: ['sm', 'md'],
class: 'px-3 py-1'
}
],
defaultVariants: {
size: 'md',
color: 'primary'
}
});
</script>
<template>
<button :class="button({ size: 'sm', color: 'secondary' })">
Click me
</button>
</template>
button({ size: 'sm', color: 'secondary' });
// font-medium bg-blue-500 color-white rounded-full active:opacity-80 bg-purple-500 color-white text-sm px-3 py-1
Every class is kept, including both bg-blue-500 from base and bg-purple-500 from the variant. See Layers for how to make the variant win.
See Variants for boolean variants, compound variants, and defaults.
Slots
Split a component into named parts and style each one.

UnoCSS Variants lets you reuse recipes instead of copying class strings, and keeps every variant typed.
See Slots.
Overrides
Pass class or className when you call the recipe. The extra classes are appended — they do not replace conflicting utilities.
button({
color: 'secondary',
class: 'bg-pink-500 hover:bg-pink-500'
});
// font-semibold color-white py-1 px-3 rounded-full active:opacity-80 bg-purple-500 hover:bg-purple-700 bg-pink-500 hover:bg-pink-500
See Overriding styles.
Composition
extend merges another recipe's base, slots, variants, defaultVariants, compoundVariants, and compoundSlots.
Child classes that must win over the parent should use the uno-layer-uv: prefix. See Composing components and Layers.
What is not included
- No class merging — unlike default Tailwind Variants,
uvnever drops conflicting utilities. - No second
configargument — and nocreateTV/twMerge/cnMerge. - No
/liteentry — there is a single build. - No
responsiveVariantsmap — writesm:/md:in the class strings. - No breakpoint autocompletion — TypeScript completes variant keys and slot names, not media queries.
Coming from Tailwind Variants? Read the migration guide.
Credits
UnoCSS Variants is a fork of Tailwind Variants. Credit to the original authors, and to Stitches and CVA for the variant model.