Tailwind Variants
Use this skill when work touches Tailwind Variants (tv, slots, compound variants, extend, cn/cx/cnMerge, /lite, or migrations across TV majors).
Workflow
- Inspect the local styling stack before changing code:
- Packages:
tailwind-variantsversion, Tailwind CSS major (v4vsv3), optional directtailwind-mergeusage, Prettier Tailwind plugin. - Import path: default
tailwind-variantsvstailwind-variants/lite. - Patterns in use: single-element
tv, slots,extend, sharedcreateTV/defaultConfig,VariantPropson components.
- Packages:
- Refresh docs when versions are unclear or work touches merge config, lite builds, or major upgrades. Start from source-map.md.
- For install, default vs lite builds,
cn/cnMerge/cx, and config, use setup-core.md. - For
variants, boolean/compound variants, slots, andcompoundSlots, use variants-slots.md. - For
extend, overrides, TypeScriptVariantProps, and DX tooling, use composition-typescript.md. - For conflict resolution, custom
twMergeConfig, and v0/v1/v2/v3 migrations, use production-migration.md.
Implementation Judgment
- Pair TV v3.x with Tailwind CSS v4.x. If the project is still on Tailwind CSS v3, use
tailwind-variantsv0.x (or upgrade Tailwind first). - Prefer the default build (
import { tv, cn } from 'tailwind-variants') for design-system work. Use/liteonly when bundle size matters and merge is unnecessary. - On v3.3.0+, conflict resolution is built into the default build—do not require
tailwind-mergesolely for TV. Keeptailwind-mergeonly if the app calls it directly. - Omit
slotsfor a string-returning recipe. Passingslots: {}enables slot mode (implicitbaseslot)—avoid accidental empty-slot objects. - Prefer
extendfor typed composition over string-splicingtvresults intobasearrays. - Use
class/classNameprops for consumer overrides; let merge resolve conflicts when enabled. - Type React/Vue props with
VariantProps<typeof recipe>. Make variants required withOmit/Requiredwhen defaults are wrong. - Do not use removed
responsiveVariants. Put responsive prefixes (md:,lg:) in the class strings themselves. - Prefer
cxover deprecatedcnBase. Prefercnfor merged joins; usecnMergeonly for per-call merge config.
Verification
Prefer the repo's existing checks. For meaningful Tailwind Variants changes, include the relevant subset:
- Typecheck for
VariantProps, slot return shapes, andextendmerges. - Unit assertions on recipe output strings for critical variant/compound combinations (especially with merge on/off).
- Visual/browser smoke for overridden slots and composed components.
- Bundle check when switching default ↔
/liteor adding heavytwMergeConfig. - IntelliSense/
tailwindFunctions: ['tv']sanity if editors stop completing classes insidetv.