className
The React prop, and DOM property, that sets an element's HTML class attribute.
In more detail
React uses className because class is a reserved word in JavaScript. Design system components accept a className from callers and merge it with their own classes rather than replacing them.
Example
<div className={`box box--${variant}`} />Related terms
- cn utility — A tiny helper, cn(...classes) = twMerge(clsx(classes)), that joins class names conditionally and then removes conflicting Tailwind classes.
- utility class — A CSS class that does one small job, such as p-4 for padding or text-white for text colour.
- prop — An input passed to a React component, written like an HTML attribute, such as size="lg" in <Button size="lg">.
- CSS — The language that describes how web pages look: colours, fonts, spacing, layout and animation.
- JSX — The HTML-like syntax used in React code, such as <Button size="lg">Save</Button>, which compiles to JavaScript function calls.
Taught in
- Class Variance Authority: Type-Safe Variant & Prop Orchestration — Design Systems & Component Engineering
- Polymorphism & Slotted Composition: The asChild Pattern — Design Systems & Component Engineering
- JSX Transpilation: createElement, JSX Runtime, React Elements — React 19 & Modern Component Architecture
- Props Contract: Immutability, Children, And Polymorphic Tags — React 19 & Modern Component Architecture
- Diffing Algorithm: Element Type Shifts And Subtree Tear Down — React 19 & Modern Component Architecture