Skip to main content

tailwindcss

A utility-first CSS framework that provides low-level classes to build custom designs without writing custom CSS.

Tailwind CSS v4 (latest v4.3.3, 2026-07-16)

v4 is configured in CSS, not JavaScript: @import "tailwindcss"; replaces the three @tailwind directives, and theme tokens go in an @theme block. tailwind.config.js is only loaded if you opt in with @config. Install with @tailwindcss/vite or @tailwindcss/postcss.

Core Concepts​

  1. Utility Classes:
    Small, single-purpose classes like text-center, bg-blue-500, p-4, etc.

    <div class="bg-gray-200 p-4 text-center">Hello, Tailwind!</div>
  2. Responsive Design:
    Use breakpoints like sm, md, lg, xl, 2xl for responsive styling.

    <div class="text-sm md:text-lg lg:text-xl">Responsive Text</div>
  3. Customization:
    Customize colors, spacing, etc. with CSS variables in an @theme block (v4), or tailwind.config.js in v3.

    @import "tailwindcss";

    @theme {
    --color-brand: oklch(60% 0.15 250);
    }
  4. State Variants:
    Apply styles on hover, focus, etc.

    <button class="bg-blue-500 hover:bg-blue-700 text-white">Hover Me</button>
  5. Dark Mode:
    Use dark: prefix for dark mode styles.

    <div class="bg-white dark:bg-gray-800 text-black dark:text-white">
    Dark Mode
    </div>

Common Utility Classes​

  • Spacing: p-4, m-2, px-6, py-3
  • Colors: text-red-500, bg-green-200
  • Typography: text-xl, font-bold, uppercase
  • Flexbox/Grid: flex, grid, justify-center, items-center
  • Borders: border, border-2, rounded-lg
  • Shadows: shadow-md, shadow-lg
tip
  1. On-demand generation (the former JIT mode) is always on since v3: only classes you use end up in the CSS.
  2. Install Tailwind Plugins for forms, typography, or aspect ratios to extend features.
  3. Play with Tailwind’s Playground: Try out Tailwind Play.

References​