What carries over
| CSS concept | How it appears in Tailwind | What you keep doing |
|---|---|---|
| Box model | Tailwind utilities like p-4, m-2, border, border-t-2 map directly to padding, margin, border-width etc. |
You still think in terms of padding, margin, width, height, and use the same visual debugging techniques (e.g., outline, devtools). |
| Specificity | Tailwind generates atomic classes with a single responsibility, so specificity is usually 0‑1‑0. | Your understanding of cascade still matters when you combine Tailwind with custom CSS or @layer directives. |
| Responsive breakpoints |
sm:, md:, lg:, xl: prefixes correspond to the same media queries you write yourself (@media (min-width: 640px) { … }). |
You keep the mobile‑first mindset and can still use min-width/max-width logic for custom rules. |
| Pseudo‑classes |
hover:, focus:, active: etc. are Tailwind’s shorthand for :hover, :focus, :active. |
Your knowledge of state‑based styling stays intact; you just apply the prefix instead of writing a selector. |
| Custom properties (CSS variables) | You can define them in a :root block or via @layer utilities and reference them with var(--my-color). |
No need to abandon variables; they integrate nicely with Tailwind’s theme config. |
| Design tokens | Tailwind’s theme section (colors, spacing, font‑sizes) is essentially a token map you already use in a design system. |
Continue to think in a token‑first way; you’ll just edit tailwind.config.js instead of a separate SCSS map. |
| Utility‑first mindset | The idea of “one class = one property” is a formalization of the utility classes you may already write manually (.u-mt-4 { margin-top: 1rem; }). |
Your habit of extracting repeatable patterns into utilities becomes the default workflow. |
| Layered CSS | Tailwind’s @layer base, components, utilities mirrors the CSS cascade layers you may already use with @layer in modern browsers. |
You still control ordering; you just place custom rules in the appropriate layer. |
What's new
Tailwind replaces hand‑written declarations with a predefined set of atomic classes. Below is a tiny UI component built with pure CSS versus Tailwind.
Pure CSS
/* style.css */
.card {
background-color: #fff;
border-radius: 0.5rem;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
padding: 1rem;
max-width: 20rem;
}
.card h2 {
font-size: 1.25rem;
margin-bottom: 0.5rem;
}
.card a {
color: #2563eb;
text-decoration: underline;
}
.card a:hover {
color: #1d4ed8;
}
<!-- index.html -->
<div class="card">
<h2>Tailwind Intro</h2>
<p>Learn the basics.</p>
<a href="#">Read more</a>
</div>
Tailwind CSS
<div class="bg-white rounded-lg shadow-md p-4 max-w-xs">
<h2 class="text-lg mb-2">Tailwind Intro</h2>
<p>Learn the basics.</p>
<a class="text-blue-600 underline hover:text-blue-800" href="#">Read more</a>
</div>
What changed and why
- No separate stylesheet – All visual rules live in the HTML class attribute, eliminating the need to maintain a parallel CSS file for simple components.
-
Design tokens are centralized –
text-lg,bg-white,rounded-lg,shadow-md,max-w-xspull values fromtailwind.config.js, guaranteeing consistency across the project. -
Responsive & state variants are inline – Adding
md:max-w-smorfocus:outline-noneis a matter of prefixing the same utility, no extra media query blocks. - Purging unused styles – Tailwind’s JIT compiler removes any class you never use, keeping the final bundle small despite the huge source set.
Common pitfalls
| Pitfall | Why it happens | How to avoid it |
|---|---|---|
| Over‑loading HTML with classes | The atomic approach can lead to long class strings (class="bg-white p-4 ..."). |
Use component extraction (@apply in a CSS file) or a templating helper (e.g., a React component) for repeated patterns. |
| Forgetting to run the JIT compiler | Tailwind generates classes on‑the‑fly; if you edit HTML without a watcher, missing classes won’t appear. | Run npm run dev (or npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch) during development. |
Misusing @apply inside @layer utilities |
@apply can only reference existing utilities; trying to apply a custom class that itself uses @apply creates a circular reference. |
Keep @apply usage to base/component layers, and avoid nesting @apply inside another @apply. |
| Ignoring the design token source | Hard‑coding values (class="text-[#123456]") bypasses the theme and makes future refactors painful. |
Prefer text-primary or text-blue-600 that map to theme.colors. |
| Assuming Tailwind eliminates all CSS | Complex interactions (e.g., custom animations, third‑party widgets) still need hand‑written CSS. | Reserve a custom.css file for edge cases and import it after Tailwind so its rules win the cascade. |
Not configuring content paths |
Tailwind’s purge step only scans files listed in content. Missing a directory means classes are stripped from production. |
Include every folder that contains HTML/JSX/TSX/Blade files: content: ['./src/**/*.{html,js,jsx,ts,tsx}']. |
| Using outdated class names | Tailwind evolves; class names can be renamed (e.g., focus:outline-none stays, but border-gray-200 may become border-gray-200/50). |
Stick to the official documentation and run npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch to see compile errors early. |
Your 30‑day plan
Week 1 – Foundations
-
Install the toolchain –
npm init -y,npm i -D tailwindcss postcss autoprefixer, then runnpx tailwindcss init -p. -
Create the input CSS –
@tailwind base; @tailwind components; @tailwind utilities;. -
Configure
content– point to all HTML/JSX files you’ll edit. - Build a “Hello Tailwind” page – replicate a simple landing page you already have in pure CSS, using only Tailwind utilities.
- Mini project: Re‑style a personal blog post header (title, author line, share buttons) exclusively with Tailwind classes.
Week 2 – Tokens, Variants, and Extraction
-
Explore
tailwind.config.js– add a custom color (brand: '#1a73e8') and a spacing scale (72: '18rem'). -
Use responsive prefixes – create a card grid that switches from 1‑column on mobile to 3‑column on
lg:screens. -
Apply state variants – implement a button with
hover:bg-brand-700 focus:ring-2. -
Introduce
@apply– extract a reusable.btn-primaryclass insrc/styles.cssand reference it in HTML. -
Mini project: Build a responsive navigation bar with a mobile hamburger, using Tailwind’s
hidden,block, andmd:prefixes.
Week 3 – Advanced Patterns
-
Learn the JIT mode – verify that arbitrary values (
bg-[#ff5722],h-[calc(100vh-4rem)]) compile on demand. -
Create a component library – define a
Cardcomponent in acomponents.cssfile using@layer componentsand@apply. -
Integrate with a framework – if you use React, set up
tailwindcsswithcracoorvite; for Vue, add the plugin invite.config.js. -
Add dark mode – enable
darkMode: 'class'in config, then toggle with adarkclass on<html>. -
Mini project: Design a product listing page with filters, using grid utilities, dark mode, and a custom
badgecomponent.
Week 4 – Polish and Production
-
Configure purge for production – ensure
NODE_ENV=productionrunstailwindcss -i ./src/input.css -o ./dist/output.css --minify. -
Audit the final CSS size – use
npx tailwindcss -i ./src/input.css -o ./dist/output.css --watchand check the generated file size. -
Add custom plugins – experiment with
require('@tailwindcss/forms')to style form elements automatically. - Write a style guide – generate a simple HTML page that documents your custom tokens, component classes, and usage conventions.
- Mini project: Refactor an existing multi‑page site (e.g., a portfolio) to use Tailwind exclusively, applying everything you’ve learned.
FAQ
How do I keep my existing CSS file while adopting Tailwind?
Import Tailwind first, then your legacy stylesheet; the cascade will let your custom rules override utilities when needed.
Is Tailwind compatible with CSS modules or SCSS?
Yes. You can use Tailwind inside a .module.scss file; just keep the @tailwind directives at the top and let the pre‑processor handle the rest.
Do I need to learn a new naming convention for colors and spacing?
Tailwind’s default naming (text-gray-700, p-4) is opinionated, but you can rename them in theme.extend to match your existing design system.
Can I use Tailwind with older browsers (IE11)?
Tailwind generates modern CSS; you’ll need a post‑CSS autoprefixer and possibly a polyfill for CSS variables if you must support IE11.
Keep going
- See what already transfers: take the free CSS → Tailwind readiness check
- The full CSS → Tailwind roadmap, topic by topic
- Related: Cloud developer learning Supabase: what carries over, what's new, 30-day plan
- Related: Vue developer learning React: what carries over, what's new, 30-day plan
Originally published at switchbyskill.com.
Top comments (0)