The Tailwind Honeymoon Ends
Tailwind is fantastic for prototyping. You get pixel-perfect designs without switching files, and the learning curve is gentle. But after a few months, the cracks show: 40-class strings, duplicated patterns, and components that are hard to read.
Here's how to keep it sustainable.
1. Group Classes by Concern
Don't let classes pile up in a random order. Group them mentally: layout, spacing, typography, color, state.
<button className="
inline-flex items-center gap-2
px-4 py-2
text-sm font-semibold
bg-orange-500 text-white
rounded-full
hover:bg-orange-600
disabled:opacity-50
">Even if you write it on one line, keeping this mental order makes diffs cleaner and reviews faster.
2. Extract Components, Not Utility Classes
The temptation is to make a .btn-primary CSS class. Don't. Instead, extract a React component.
export function PrimaryButton({ children, ...props }) {
return (
<button
{...props}
className="rounded-full bg-orange-500 px-4 py-2 text-sm font-semibold text-white hover:bg-orange-600"
>
{children}
</button>
);
}This keeps the utility-first mindset but gives you a single source of truth.
3. Use Your Design Tokens
Instead of hard-coding colors like bg-gray-50, use semantic tokens defined in your config: bg-muted, bg-card, text-muted-foreground