Patterns

Conditional className

Select fixed class names from props or state without discarding the base class.

Formal Syntax & Structure

react syntaxreact
className={active ? `${base} ${variant}` : base}

Working Example

Example Snippetreact
<article className={featured ? "card featured" : "card"} />
React Reference