Article Title
Published on Nov 2, 2025
Article content with optimal line length for reading...
More content...
# Layout Patterns **Master the 5 essential layouts** that cover 80% of all interface needs. Learn when to use Grid vs Flex, and build responsive, consistent layouts every time. --- ## Table of Contents 1. [Grid vs Flex Decision Tree](#grid-vs-flex-decision-tree) 2. [The 5 Essential Patterns](#the-5-essential-patterns) 3. [Responsive Strategies](#responsive-strategies) 4. [Common Mistakes](#common-mistakes) 5. [Advanced Patterns](#advanced-patterns) --- ## Grid vs Flex Decision Tree Use this flowchart to choose between Grid and Flex: ``` ┌─────────────────────────────────────┐ │ Need equal-width columns? │ │ (e.g., 3 cards of same width) │ └──────────┬─YES──────────┬─NO────────┘ │ │ ▼ ▼ USE GRID Need 2D layout? (rows + columns) │ ┌────┴────┐ │YES │NO ▼ ▼ USE GRID USE FLEX ``` ### Quick Rules | Scenario | Solution | | --------------------------- | ------------------------------------------------------- | | **Equal-width columns** | Grid (`grid grid-cols-3`) | | **Flexible item sizes** | Flex (`flex gap-4`) | | **2D layout (rows + cols)** | Grid (`grid grid-cols-2 grid-rows-3`) | | **1D layout (row OR col)** | Flex (`flex` or `flex flex-col`) | | **Card grid** | Grid (`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3`) | | **Navbar items** | Flex (`flex items-center gap-4`) | | **Sidebar + Content** | Flex (`flex gap-6`) | | **Form fields** | Flex column (`flex flex-col gap-4` or `space-y-4`) | --- ## The 5 Essential Patterns These 5 patterns cover 80% of all layout needs. Master these first. --- ### 1. Page Container Pattern **Use case**: Standard page layout with readable content width ```tsx
{item.value}
Published on Nov 2, 2025
Article content with optimal line length for reading...
More content...
Body text stays consistent
``` --- ## Common Mistakes ### ❌ Mistake 1: Using Margins Instead of Gap ```tsx // ❌ WRONG - Children have margins