DEV Community

Switch by Skill
Switch by Skill

Posted on Originally published at switchbyskill.com

CSS developer learning Tailwind: what carries over, what's new, 30-day plan

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;
}
Enter fullscreen mode Exit fullscreen mode
<!-- index.html -->
<div class="card">
  <h2>Tailwind Intro</h2>
  <p>Learn the basics.</p>
  <a href="#">Read more</a>
</div>
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

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-xs pull values from tailwind.config.js, guaranteeing consistency across the project.
  • Responsive & state variants are inline – Adding md:max-w-sm or focus:outline-none is 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

  1. Install the toolchain – npm init -y, npm i -D tailwindcss postcss autoprefixer, then run npx tailwindcss init -p.
  2. Create the input CSS – @tailwind base; @tailwind components; @tailwind utilities;.
  3. Configure content – point to all HTML/JSX files you’ll edit.
  4. Build a “Hello Tailwind” page – replicate a simple landing page you already have in pure CSS, using only Tailwind utilities.
  5. Mini project: Re‑style a personal blog post header (title, author line, share buttons) exclusively with Tailwind classes.

Week 2 – Tokens, Variants, and Extraction

  1. Explore tailwind.config.js – add a custom color (brand: '#1a73e8') and a spacing scale (72: '18rem').
  2. Use responsive prefixes – create a card grid that switches from 1‑column on mobile to 3‑column on lg: screens.
  3. Apply state variants – implement a button with hover:bg-brand-700 focus:ring-2.
  4. Introduce @apply – extract a reusable .btn-primary class in src/styles.css and reference it in HTML.
  5. Mini project: Build a responsive navigation bar with a mobile hamburger, using Tailwind’s hidden, block, and md: prefixes.

Week 3 – Advanced Patterns

  1. Learn the JIT mode – verify that arbitrary values (bg-[#ff5722], h-[calc(100vh-4rem)]) compile on demand.
  2. Create a component library – define a Card component in a components.css file using @layer components and @apply.
  3. Integrate with a framework – if you use React, set up tailwindcss with craco or vite; for Vue, add the plugin in vite.config.js.
  4. Add dark mode – enable darkMode: 'class' in config, then toggle with a dark class on <html>.
  5. Mini project: Design a product listing page with filters, using grid utilities, dark mode, and a custom badge component.

Week 4 – Polish and Production

  1. Configure purge for production – ensure NODE_ENV=production runs tailwindcss -i ./src/input.css -o ./dist/output.css --minify.
  2. Audit the final CSS size – use npx tailwindcss -i ./src/input.css -o ./dist/output.css --watch and check the generated file size.
  3. Add custom plugins – experiment with require('@tailwindcss/forms') to style form elements automatically.
  4. Write a style guide – generate a simple HTML page that documents your custom tokens, component classes, and usage conventions.
  5. 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

Originally published at switchbyskill.com.

Top comments (0)