Back to Home
    Tailwind CSSTailwind CSS v4Beginner

    Tailwind CSS

    Tailwind utility classes for layout, spacing, typography, flexbox, grid, and responsive design.

    8 min read
    tailwindcssutilityfrontend

    Layout

    2 topics

    Flexbox

    html
    <!-- Flex container -->
    <div class="flex items-center justify-between gap-4">
      <span>Left</span>
      <span>Right</span>
    </div>
    
    <!-- Common flex patterns -->
    flex flex-col          /* vertical stack */
    flex items-center      /* vertical center */
    flex justify-center    /* horizontal center */
    flex items-center justify-center  /* both center */
    flex flex-wrap gap-2   /* wrapping with gap */
    flex-1                 /* grow to fill space */
    flex-none              /* don't grow/shrink */

    💡 flex items-center justify-center is the classic centering combo

    Grid

    html
    <!-- Responsive grid -->
    <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
      <div>Card</div>
    </div>
    
    <!-- Grid utilities -->
    grid-cols-{n}      /* fixed columns */
    grid-cols-none     /* no grid */
    col-span-2         /* span 2 columns */
    col-span-full      /* span all columns */
    row-span-2         /* span 2 rows */
    gap-4              /* gap between items */
    gap-x-4 gap-y-2    /* separate x/y gap */
    place-items-center /* center items in cells */

    ⚡ grid-cols-[repeat(auto-fill,minmax(250px,1fr))] creates a truly responsive grid without breakpoints

    Spacing & Sizing

    1 topic

    Margin, Padding, Size

    html
    <!-- Scale: 1 = 0.25rem (4px) -->
    p-4         /* padding: 1rem (16px) */
    px-4 py-2   /* horizontal/vertical padding */
    pt-2 pb-4   /* top/bottom padding */
    m-4         /* margin: 1rem */
    mx-auto     /* horizontal center block */
    -mt-2       /* negative margin */
    
    /* Sizing */
    w-full      /* width: 100% */
    w-1/2       /* width: 50% */
    w-64        /* width: 16rem (256px) */
    w-screen    /* 100vw */
    max-w-xl    /* max-width: 36rem */
    max-w-7xl   /* max-width: 80rem — common page width */
    h-screen    /* height: 100vh */
    min-h-screen

    💡 mx-auto is the standard way to center a fixed-width container

    Responsive & Dark Mode

    1 topic

    Breakpoints & Variants

    html
    <!-- Breakpoints: sm(640) md(768) lg(1024) xl(1280) 2xl(1536) -->
    <div class="text-sm md:text-base lg:text-lg">
      Responsive text
    </div>
    
    <!-- Dark mode -->
    <div class="bg-white dark:bg-gray-900 text-black dark:text-white">
      Adapts to system preference
    </div>
    
    <!-- Hover, focus, active -->
    <button class="bg-blue-500 hover:bg-blue-600 focus:ring-2 active:scale-95">
      Click me
    </button>
    
    <!-- Group hover -->
    <div class="group">
      <p class="opacity-0 group-hover:opacity-100">Revealed on hover</p>
    </div>

    💡 Tailwind is mobile-first — unprefixed classes apply to all sizes, sm: and up override

    ⚡ group and peer variants enable parent/sibling state targeting

    Related Articles

    Background reading and deeper explanations for this sheet.

    AI Product Pricing Strategies: How to Monetize for Growth, Margin, and Customer Trust

    Pricing an AI product is not just a finance decision—it shapes adoption, retention, margins, and user trust. In this practical guide, you’ll learn how to choose the right pricing model, align price with value and costs, and avoid common mistakes using real-world examples and implementation frameworks.

    keyword overlap

    Event-Driven Agents with Kafka Streams: A Practical Guide for Building Real-Time AI Workflows

    Event-driven agents let you move from slow, request/response automation to responsive systems that react in milliseconds to real-world signals. In this hands-on guide, you’ll learn how to design, build, and operate agentic workflows using Apache Kafka and Kafka Streams, with practical patterns, code snippets, and production-ready advice.

    keyword overlap

    Best CRM for Agencies in 2026: What Actually Matters?

    Choosing the right CRM can transform how your agency manages leads, projects, clients, invoices, and support. This guide compares cloud and self-hosted CRM solutions and explains why agencies are increasingly choosing flexible platforms like DevPremier CRM.

    keyword overlap

    Building Autonomous Agents Without Overengineering: A Practical Guide for Real-World Teams

    Autonomous agents can automate meaningful work, but many projects fail because teams overbuild too early. This practical guide shows you how to design, ship, and improve useful agents with simple patterns, clear guardrails, and real-world examples—without turning your stack into a science project.

    keyword overlap