pageweave/resources

Responsive & Adaptive Layout

Build responsive layouts with fluid grids, container queries, and adaptive patterns that work from 320px to ultrawide — no breakpoint chaos.

· .md · source ↗

Build layouts that serve the content at every viewport — from 320px phones to ultrawide monitors. Mobile-first, fluid by default, with breakpoints only where the design genuinely needs them.

Mobile-First Workflow

Always start at the smallest viewport (375px) and scale up with min-width media queries. This forces you to prioritize content and progressive enhancement.

/* Base: mobile (375px) */
.grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }

/* Tablet (768px+) */
@media (min-width: 768px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 2rem; }
}

Rules:

Fluid Layouts Without Breakpoints

Many responsive needs can be solved without media queries:

Auto-fit Grids

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.5rem;
}

This creates a grid that:

Fluid Spacing

section {
  padding-block: clamp(2rem, 1.5rem + 2.5vw, 4rem);
}

Fluid Typography

h1 {
  font-size: clamp(2rem, 1.5rem + 2.5vw, 3.5rem);
}

Container Queries

When components need to respond to their container, not the viewport:

.card-container { container-type: inline-size; }

@media (min-width: 400px) {
  .card { flex-direction: row; }
}

Use container queries for:

Layout Patterns

The Holy Grail (Adaptive)

.page {
  display: grid;
  grid-template-areas:
    "header"
    "main"
    "footer";
  min-height: 100dvh;
}

@media (min-width: 768px) {
  .page {
    grid-template-columns: 240px 1fr;
    grid-template-areas:
      "header header"
      "sidebar main"
      "footer footer";
  }
}

The Dashboard Shell

.dashboard {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100dvh;
}

.sidebar { grid-row: 1 / -1; }
.topbar { grid-column: 2; }
.content { grid-column: 2; overflow: auto; }

At mobile: sidebar becomes a drawer (off-canvas, toggled by hamburger).

The Content Layout

.article {
  max-width: 65ch;
  margin-inline: auto;
  padding-inline: 1rem;
}

.article-wide {
  max-width: min(100% - 2rem, 900px);
  margin-inline: auto;
}

Breakpoint Strategy

Don't add breakpoints because "it looks wrong." Add them because the layout pattern genuinely changes.

Breakpoint Typical device When to add
640px Large phone Navigation pattern changes
768px Tablet Grid columns increase, sidebar appears
1024px Small laptop Full navigation, wider content
1280px Desktop Maximum content width, side panels
1536px Large desktop Wider gutters, additional columns

Adaptive Width Classes (Material Design 3 Model)

Class Width Layout
Compact < 600px Single column, bottom nav
Medium 600–839px 2 columns, nav rail or drawer
Expanded 840–1199px 2–3 columns, persistent nav
Large 1200–1599px Full layout, side panels
Extra large ≥ 1600px Maximum content width, generous gutters

Common Responsive Problems

Text Overflow

Long heading words + large clamp scales + narrow grids cause headline overflow on tablet/mobile.

Fix: test the longest heading copy at every breakpoint. If it overflows, reduce the clamp max or rewrite the copy. The viewport is part of the design.

Images

img {
  max-width: 100%;
  height: auto;
  aspect-ratio: 16 / 9; /* prevent layout shift */
  object-fit: cover;
}

Tables

Wide data tables don't fit mobile. Options:

Fixed-Width Elements

Never use fixed pixel widths for layout containers. Use max-width with fluid inner content:

.container {
  max-width: min(100% - 2rem, 1200px);
  margin-inline: auto;
}

Testing Checklist

PageWeave-Specific

PageWeave uses Tailwind CSS v4. Use Tailwind's responsive utilities:

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 md:gap-6">

Tailwind breakpoints: sm (640px), md (768px), lg (1024px), xl (1280px), 2xl (1536px).

For container queries in Tailwind v4:

<div class="@container">
  <div class="@md:flex-row flex-col">

Anti-Patterns