Krizaka UI
Krizaka UI
ComponentsFoundations

cn

Joins class names and resolves Tailwind conflicts: the last class wins.

Web · ✓Mobile · n/aDesktop · ✓StableUtilities & brand
Support level
Stable
Size
0.5 kB gzip, budget 14.0 kB
Who uses it
51 files of the live products and sites import it (Folioviv: 5, Sovkora: 30, krizaka.com: 4) Counted in the dated inventory of 2026-11-23.
import { cn } from "@krizaka/ui/cn";

The last class wins: px-4 replaces px-3, and the selected colours replace the idle ones.

Web only — React, from @krizaka/ui/cn. Stable: its API only changes in a major version.

  • Mobile · n/a. Class names are the web's styling; React Native styles with StyleSheet and the theme's roles.

Why it is here. Used by Sovkora, krizaka.com.

When to use

  • To build a className from conditions in a product component.
  • To let a caller's className override a component's classes.

When not to use

  • To define the variants of a component: use tv() from tailwind-variants, like the primitives.
  • To pass props and classes to a child element.Use instead: Slot

Installation

Install

npm install @krizaka/ui @krizaka/tailwind @krizaka/tokens tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Import

import { cn } from "@krizaka/ui/cn";

Examples

Merge

The last class wins: px-4 replaces px-3, the selected colours replace the idle ones.

The last class wins: px-4 replaces px-3, and the selected colours replace the idle ones.

Props

This module has no component props: see the import and the preview above.

Accessibility

  • No effect on accessibility: it only computes a class string.

Best practices

  • Put the caller's className last: cn(base, conditional, className).
  • One cn per app: it shares the merge engine of the primitives.

Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page