clsx

A tiny JavaScript function that builds a class string from strings, objects and conditions, skipping anything falsy.

In more detail

clsx("btn", { active: isActive }, disabled && "opacity-50") returns only the parts whose conditions are truthy. It does not know about Tailwind conflicts, which is why cn passes its result through tailwind-merge.

Related terms

Taught in

References