"I stopped writing CSS files three years ago. I've never moved faster."
Class names like .sidebar-wrapper-inner-container are dead. They are semantic drift waiting to happen.
Tailwind CSS is not "inline styles". Inline styles don't have constraints. Inline styles don't respond to hover states. Inline styles don't handle media queries.
Tailwind is an API for your Design System.
02. The JIT Compiler (Magic)
In the old days (v2), Tailwind generated a 10MB CSS file and stripped unused styles later.
The JIT (Just-In-Time) Engine watches your files. It sees top-[117px] and instantly generates a single CSS rule: `.top-[117px] { top: 117px }`.
This means:
- ⚡ Zero development lag.
- 📦 Tiny production CSS bundles (only what you use).
- 🎨 Arbitrary values for when you need pixel-perfect precision.
03. Mobile-First Strategy
Tailwind forces you to think Mobile First. Unprefixed utilities (like `block`) target mobile. Prefixed utilities (like `md:flex`) target larger screens.
❌ Common Mistake
class="flex sm:block"
This means "Flex on mobile, Block on tablet". Usually inverted intent.
✅ Correct Thinking
class="block md:flex"
"Default is block (mobile). On medium screens and up, become flex."
04. Theme Extension & Config
Never override. Always extend. In your `tailwind.config.js`, use the extend key to preserve the default utilities while adding your own branding.
module.exports = {
theme: {
extend: {
colors: {
brand: {
DEFAULT: '#0fa9e6',
dark: '#0c87b8',
}
},
fontFamily: {
sans: ['Inter', 'sans-serif'],
}
}
}
}
Now you can use `bg-brand` and `font-sans` in your markup.
05. CVA: The New BEM
"But my HTML is ugly!"
Soltuion: Use CVA (Class Variance Authority) to type-safe your components. It keeps your template clean and your logic centralized.
const button = cva("rounded-xl font-bold transition items-center justify-center", {
variants: {
intent: {
primary: "bg-blue-500 text-white hover:bg-blue-600",
secondary: "bg-gray-200 text-black hover:bg-gray-300",
},
size: {
sm: "px-4 py-2 text-sm",
lg: "px-8 py-4 text-lg",
}
},
defaultVariants: {
intent: "primary",
size: "lg"
}
})
07. Utility Builder
Compose utility classes visually and watch the button transform instantly. This simulates the JIT engine applying styles.
Tool Token Composer
Mix and match Padding, Color, and Radius tokens.