utility class
A CSS class that does one small job, such as p-4 for padding or text-white for text colour.
In more detail
Utility classes are combined in the class attribute instead of writing a custom stylesheet per component. In Tailwind version 4 each colour utility reads a theme variable, so bg-brand means background-color: var(--color-brand).
Example
In the browser: Utility-first CSS frameworks are built almost entirely from such classes. Utilities usually live in the last cascade layer so they always win over components, regardless of specificity.Related terms
- Tailwind CSS — A CSS framework made of small single-purpose utility classes, such as bg-blue-600 or px-4, that you combine in markup.
- className — The React prop, and DOM property, that sets an element's HTML class attribute.
- cn utility — A tiny helper, cn(...classes) = twMerge(clsx(classes)), that joins class names conditionally and then removes conflicting Tailwind classes.
- cascade layer — A named group of CSS rules, declared with @layer, whose priority in the cascade is set by layer order instead of selector specificity.
- design system — A shared set of design decisions, reusable components and rules that keeps every screen of a company's products looking and behaving the same way.
Taught in
- Tailwind CSS v4 Engine: CSS Variables & Theme Extensions — Design Systems & Component Engineering
- Class Variance Authority: Type-Safe Variant & Prop Orchestration — Design Systems & Component Engineering
- Headless Architecture: State vs Presentation Separation — Design Systems & Component Engineering
- CSS Cascade Layers: Taming Specificity Wars with @layer — Frontend Architecture & Web Platform