Introduction to Tailwind CSS

Tailwind CSS is a highly customizable, low-level, utility-first CSS framework that gives you all of the building blocks you need to build bespoke user interfaces without any annoying opinionated styles you have to fight to override.

Key Concept: Unlike traditional frameworks like Bootstrap or Bulma that provide pre-styled components (e.g. .btn or .card), Tailwind CSS provides primitive utility classes like bg-blue-500, px-4, py-2, and rounded-lg to compose any layout directly in your HTML.

What is Utility-First CSS?

Traditional CSS architecture encourages writing custom CSS classes for every component. Over time, CSS files grow exponentially in size, resulting in duplicate code, specificity wars, and difficult maintenance.

In a utility-first approach, you write single-purpose CSS classes directly in your markup. Tailwind generates only the CSS you actually use during production builds via Tree-Shaking (Purge CSS / JIT Engine).

Live Demo: Custom Card in Tailwind CSS

Rendered using Tailwind CSS utility classes:

TW
Tailwind Utility Example
Building Modern UIs at Lightning Speed

No custom CSS files created. Everything styled directly via utility classes!

Tailwind HTML Code:
<div className="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden p-4">
  <div className="md:flex items-center gap-4">
    <div className="w-16 h-16 rounded-full bg-indigo-500 text-white flex items-center justify-center font-bold text-2xl">
      TW
    </div>
    <div>
      <div className="uppercase tracking-wide text-sm text-indigo-500 font-semibold">Tailwind Utility Example</div>
      <a href="#" className="block mt-1 text-lg font-medium text-black hover:underline">
        Building Modern UIs at Lightning Speed
      </a>
      <p className="mt-2 text-gray-500 text-sm">No custom CSS files created!</p>
    </div>
  </div>
</div>

Tailwind CSS vs Bootstrap

FeatureTailwind CSSBootstrap
ArchitectureUtility-First (Low Level)Component-Based (High Level)
Customizability100% Flexible, infinite designsLooks like Bootstrap out-of-the-box
CSS File SizeTiny in production (~10-20KB purged)Medium to Large (~150KB+)
Naming ClassesNo need to invent class namesPre-defined class names (`.btn`, `.nav`)
Learning CurveRequires learning utility tokensVery quick for beginners

Why Choose Tailwind CSS?

  • 1. Faster UI Development: Stop jumping back and forth between HTML and CSS files.
  • 2. Consistent Design Tokens: Colors, spacing, typography, and shadows follow a harmonious theme scale.
  • 3. Zero Unused CSS: Purge CSS automatically strips out every unused class, ensuring blazing fast page loads.
  • 4. Built-in Responsive & State Variant Modifiers: Use prefixes like hover:, focus:, md:, and dark: effortlessly.

Ready to Get Started?

Learn how to install and integrate Tailwind CSS into your projects in the next topic.

Next Lesson: Installation & Setup →