Part 2 of a series on writing Tailwind v4 without copy-pasting class lists. Part 1 drew the map. This part is the idea underneath it.
Part 1 ended with a Button component that still has rounded-full px-5 py-2 font-semibold shadow-md inside it. Long. I promised that was never the problem.
So I tested the opposite worry. I generated 100 cards with random class lists and built them with Tailwind 4.3.3. Then I generated 1,000.1
100 components 9,459 bytes1,000 components 9,459 bytesTen times the markup, the same stylesheet to the byte. To see why, you have to stop reading a class list as styling and start reading it as something else.
The class list that looks wrong
Here’s the reaction most of us have the first time, and I had it too. class="p-6 rounded-lg bg-white shadow-sm" looks like inline styles in a trench coat. It breaks separation of concerns. The HTML spec even says so, kind of: authors “are encouraged to use values that describe the nature of the content, rather than values that describe the desired presentation of the content.”2
Encouraged. The same sentence says there are “no additional restrictions on the tokens authors can use.” It’s advice, and the advice had a cost nobody put in the spec.
Adam Wathan wrote that cost down in 2017, in the essay that became Tailwind’s founding text.3 He started with a content-named class, .author-bio, and kept refactoring. Name your classes after content and “your HTML is restyleable, but your CSS is not reusable.” Name them after patterns, like .media-card, and “your CSS is reusable, but your HTML is not restyleable.” The coupling never goes away. It only picks a direction. “Neither is inherently ‘wrong’,” he wrote, and he still had to invent a name for every box on the page: “Trying to come up with these component names all of the time is exhausting.”
A utility is a decision, not a declaration
Here’s what p-6 compiles to in 4.3.3:
.p-6 { padding: calc(var(--spacing) * 6);}It doesn’t say 24 pixels. It says step 6 of the spacing scale, and the theme decides what a step is. text-slate-700 compiles to color: var(--color-slate-700). Every utility points back at the theme.
That’s the first answer to “isn’t this inline styles?” The docs admit that “in some ways it is,” then name the difference: “using inline styles, every value is a magic number. With utilities, you’re choosing styles from a predefined design system.”4 A class list is a list of choices from a fixed menu. It’s the same idea as treating design values as decisions, with the menu written into the class names.
The second answer is what the style attribute can’t hold. It takes declarations and nothing else.5 No selector, so no :hover. No at-rule, so no breakpoint. A utility can carry a condition, and each one carries exactly one:
@media (hover: hover) { .hover\:bg-sky-700:hover { background-color: var(--color-sky-700); }}@media (width >= 40rem) { .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }}@media (prefers-color-scheme: dark) { .dark\:bg-gray-800 { background-color: var(--color-gray-800); }}The docs say hover:bg-sky-700 “does nothing unless the element is hovered,” and that a single class “will never include both the light and dark styles.”6 A traditional .btn holds every state in one name. A utility holds one decision under one condition. (The @media (hover: hover) wrapper is new in v4. Part 3 covers it.)
Why the stylesheet stops growing
The docs list the benefits, and three of them do the real work.7
Locality. “Adding or removing a utility class to an element only ever affects that element.” No other page uses that list, so no other page breaks when you change it.
Constraint. Everyone picks from the same menu, so the menu stays small. Wathan’s essay quotes 2017 stats for GitLab’s stylesheet: “402 text colors, 239 background colors, 59 font sizes.” Those are the essay’s numbers, not GitLab’s today. They show what happens when “every new chunk of CSS you write is a blank canvas.”3
Bounded CSS. Tailwind generates only the classes it finds in your source. Once every class on the menu is in use somewhere, a new component adds nothing to the stylesheet. That’s the 9,459 bytes from the top.
To see the shape, here’s the same generator with a second version. Each component gets its own named class, .card-0 to .card-999, with the same utilities applied inside it. It stands in for “write new CSS for every component.” It’s synthetic: hand-written CSS would share some rules, and it would also drift in value, which is the essay’s 402 colours.
At 10 components the two are within 53 bytes gzipped. At 1,000, the per-component CSS is 674 KB minified, and gzip squeezes it to 19 KB, against 2.6 KB for utilities. Part 1’s rule still holds: bundle size is a weak argument, and gzip takes most of it away. Part 23 measures a real app.
The argument is the shape. One line goes flat once the vocabulary is in use. The other climbs with every feature you ship. The docs put it as “your CSS doesn’t continue to grow linearly with every new feature.”7 Your stylesheet ends up sized by your design system, not by your feature list.
Tailwind reads your source as plain text
There’s one practical rule that falls out of this model, and it bites everyone once.
If the menu is a vocabulary, Tailwind is the reader. It “treats all of your source files as plain text,” and “has no way of understanding string concatenation or interpolation.”8 I put this in a Svelte file:
<script> let { color } = $props();</script>
<button class="bg-{color}-600">dynamic</button>The build passed. The CSS had no bg-*-600 rule from it at all. The string bg-red-600 never appears in the source, so as far as Tailwind knows, nobody asked for it.
The fix is the one part 1’s looks object already used: write every class name out in full, and pick between them.
What utilities replace, and what they don’t
Here’s a made-up profile card, written the BEM way: a name for each part, a rule for each name, and values picked by eye.
The <style> block is gone, and with it two names nobody needed. The 22 pixels and the 7 pixels snapped to 24px and 8px, steps on the scale. Nobody has to ask “is .profile-card__name still used anywhere?” before deleting it, because there’s nothing to delete.
That’s the list of what utilities replace: the naming layer, the hop between HTML and CSS files, and the fear of dead CSS. They also replace making a component of everything up front. Wathan’s rule was to “build everything I can out of utilities, and only extract repeating patterns as they emerge.” His example was the navbar: it’s written once in the layout, so it never needs a name.3
In 2017 he extracted those patterns into CSS classes. The v4 docs and part 1 now say to reach for a component first. The idea stayed. The tool for extracting changed.
What utilities don’t replace is the rest of part 1’s map. Repeated markup still wants a component. A repeated value still wants a token. And a value that only exists at runtime, like a colour from your database, still goes in style, as a CSS variable a utility can read.9
What it costs
- Long lists are hard to scan. Twelve classes on one element take a moment to read. Part 20 is about keeping them readable.
- The HTML isn’t restyleable from CSS alone. That’s Wathan’s trade, picked on purpose. A CSS Zen Garden redesign, where only the stylesheet changes, doesn’t work here.
- You have to learn the vocabulary.
p-6means nothing until you know the scale. It’s a small menu, but it’s a menu. - Arbitrary values bring magic numbers back.
bg-[#316ff6]is an escape hatch, and part 17 covers when to use it.
The repetition is the point
The long class list is a list of decisions you already made. Seeing font-semibold in two hundred places isn’t duplication. It’s two hundred places that agree.
What part 1 fixes is different: the same combination of classes, copied across files. That’s a decision with no home yet. The repeated words were never the problem.
If you want to read ahead, the “Styling with utility classes” page in the Tailwind docs is the official version of this argument, and Wathan’s 2017 essay is the long one.73
Next in the series:
The next parts aren’t out yet — check back soon.
Footnotes
-
tailwindcssand@tailwindcss/cli4.3.3 on macOS, built withnpx @tailwindcss/cli -i in.css -o out.css --minifyand measured withgzip -9. Each component draws one class from each of 10 groups (padding, background, text colour, text size, radius, shadow, weight, display, gap, hover colour), 39 classes in total, from a seeded random generator. About 6.7 KB of every build is Preflight and the theme variables. ↩ -
WHATWG, HTML Living Standard: Classes. ↩
-
Adam Wathan, “CSS Utility Classes and ‘Separation of Concerns’”, August 7, 2017. It predates Tailwind v1, so read the extraction advice as history. ↩ ↩2 ↩3 ↩4
-
Tailwind CSS, Styling with utility classes: Why not just use inline styles? ↩
-
MDN, The style global attribute. ↩
-
Tailwind CSS, Styling with utility classes: Thinking in utility classes. The docs’ sample output is “slightly simplified”; the blocks above are the real 4.3.3 output. ↩
-
Tailwind CSS, Styling with utility classes. The old
/docs/utility-firstURL redirects here. ↩ ↩2 ↩3 -
Tailwind CSS, Detecting classes in source files. ↩
-
Tailwind CSS, Styling with utility classes: When to use inline styles. ↩

