Responsive Layout Master
Build fluid, responsive layouts using CSS Grid, container queries, clamp(), and mobile-first design that adapt from 320px phones to 4K displays without breakpoint jank.
Activation Triggers
Activate on: responsive layout implementation, CSS Grid complex layouts, clamp() fluid sizing, container queries for component responsiveness, mobile-first breakpoint strategy, "layout breaks at X width", sidebar/content/aside patterns.
NOT for: theming/tokens/colors -- use css-in-js-architect. Animating layout changes -- use animation-system-architect. Component library grid systems -- use design-system-creator.
Quick Start
- Start mobile-first -- write base styles for 320px, then add complexity with
min-width media queries.
- Use CSS Grid for page layout --
grid-template-areas for the main shell (header, sidebar, content, footer).
- Use
clamp() for fluid sizing -- clamp(1rem, 0.5rem + 1.5vw, 2rem) smoothly scales between min and max.
- Apply container queries -- components that live in variable-width containers (sidebars, modals) should use
@container instead of @media.
- Test at all widths -- drag the browser from 320px to 2560px; there should be no "broken" widths.
Core Capabilities
| Domain |
Technologies |
Key Patterns |
| Page Layout |
CSS Grid, grid-template-areas |
Named areas, auto-fill, minmax() |
| Component Layout |
Flexbox, CSS Grid |
Intrinsic sizing, gap, align/justify |
| Fluid Sizing |
clamp(), min(), max(), viewport units |
Smooth scaling without breakpoints |
| Container Queries |
@container, container-type |
Component-intrinsic responsiveness |
| Fluid Typography |
clamp() on font-size, line-height |
Readable text at every viewport width |
| Breakpoint Strategy |
Mobile-first min-width, Tailwind sm:md:lg: |
Additive complexity approach |
Architecture Patterns
Pattern 1: CSS Grid Page Shell
.app-shell {
display: grid;
min-height: 100dvh;
grid-template-areas:
"header"
"main"
"footer";
grid-template-rows: auto 1fr auto;
}
@media (min-width: 768px) {
.app-shell {
grid-template-areas:
"header header"
"sidebar main"
"footer footer";
grid-template-columns: 280px 1fr;
grid-template-rows: auto 1fr auto;
}
}
@media (min-width: 1280px) {
.app-shell {
grid-template-areas:
"header header header"
"sidebar main aside"
"footer footer footer";
grid-template-columns: 280px 1fr 320px;
}
}
.header { grid-area: header; }
.sidebar { grid-area: sidebar; }
.main { grid-area: main; }
.aside { grid-area: aside; }
.footer { grid-area: footer; }
320px (mobile) 768px (tablet) 1280px+ (desktop)
┌──────────────┐ ┌───────────────────┐ ┌──────────────────────┐
│ header │ │ header │ │ header │
├──────────────┤ ├──────┬────────────┤ ├──────┬────────┬──────┤
│ │ │ side │ │ │ side │ │ aside│
│ main │ │ bar │ main │ │ bar │ main │ │
│ │ │ │ │ │ │ │ │
├──────────────┤ ├──────┴────────────┤ ├──────┴────────┴──────┤
│ footer │ │ footer │ │ footer │
└──────────────┘ └───────────────────┘ └──────────────────────┘
Pattern 2: Fluid Typography System
:root {
/* Fluid type scale: min @ 320px → max @ 1280px */
--text-sm: clamp(0.8rem, 0.74rem + 0.3vw, 0.875rem);
--text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
--text-lg: clamp(1.125rem, 0.95rem + 0.85vw, 1.5rem);
--text-xl: clamp(1.25rem, 0.9rem + 1.7vw, 2rem);
--text-2xl: clamp(1.5rem, 0.8rem + 3.3vw, 3rem);
--text-3xl: clamp(2rem, 0.7rem + 5vw, 4rem);
/* Fluid spacing */
--space-sm: clamp(0.5rem, 0.3rem + 1vw, 1rem);
--space-md: clamp(1rem, 0.5rem + 2vw, 2rem);
--space-lg: clamp(1.5rem, 0.5rem + 4vw, 4rem);
--space-xl: clamp(2rem, 0.5rem + 6vw, 6rem);
}
body { font-size: var(--text-base); }
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
Pattern 3: Auto-Fill Grid for Card Layouts
/* Cards auto-fill available space: minimum 280px, expand to fill */
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
gap: var(--space-md);
}
This single rule handles 1-column (mobile), 2-column (tablet), 3-column (desktop), and 4-column (wide) without any media queries.
Anti-Patterns
- Max-width media queries (desktop-first) --
@media (max-width: 768px) leads to overriding desktop styles for mobile. Use min-width (mobile-first) so complexity is added, not subtracted.
- Fixed pixel breakpoints without fluid behavior -- layout jumps from 1-column to 3-column with no transition. Use
clamp() and auto-fill/auto-fit for smooth adaptation.
100vw causing horizontal scroll -- 100vw includes the scrollbar width. Use 100% or 100dvw for the content area width.
- Viewport media queries for components in variable containers -- a card in a sidebar is 300px wide even on a 1920px screen. Use
@container queries for component-level responsiveness.
- Hardcoded heights --
height: 600px on a container overflows on small screens. Use min-height or let content determine height.
Quality Checklist
1---
2license: Apache-2.0
3name: responsive-layout-master
4description: "Build responsive layouts with CSS Grid, container queries, fluid typography, clamp(), and mobile-first design. Activate on: responsive design, CSS Grid layout, fluid spacing, container queries, mobile-first, breakpoints. NOT for: styling/theming (use css-in-js-architect), animation layout changes (use animation-system-architect)."
5allowed-tools: Read,Write,Edit,Bash(npm:*,npx:*)
6category: Frontend & UI
7tags:
8 - responsive-design
9 - css-grid
10 - container-queries
11 - fluid-typography
12 - mobile-first
13pairs-with:
14 - skill: web-design-expert
15 reason: Layout execution follows design intent for responsive breakpoints
16 - skill: css-in-js-architect
17 reason: Responsive layout coordinates with token-based spacing and theming
18metadata:
19 source: https://skillmd.com/skills/curiositech/responsive-layout-master
20---
21
22# Responsive Layout Master
23
24Build fluid, responsive layouts using CSS Grid, container queries, `clamp()`, and mobile-first design that adapt from 320px phones to 4K displays without breakpoint jank.
25
26## Activation Triggers
27
28**Activate on**: responsive layout implementation, CSS Grid complex layouts, `clamp()` fluid sizing, container queries for component responsiveness, mobile-first breakpoint strategy, "layout breaks at X width", sidebar/content/aside patterns.
29
30**NOT for**: theming/tokens/colors -- use css-in-js-architect. Animating layout changes -- use animation-system-architect. Component library grid systems -- use design-system-creator.
31
32## Quick Start
33
341. **Start mobile-first** -- write base styles for 320px, then add complexity with `min-width` media queries.
352. **Use CSS Grid for page layout** -- `grid-template-areas` for the main shell (header, sidebar, content, footer).
363. **Use `clamp()` for fluid sizing** -- `clamp(1rem, 0.5rem + 1.5vw, 2rem)` smoothly scales between min and max.
374. **Apply container queries** -- components that live in variable-width containers (sidebars, modals) should use `@container` instead of `@media`.
385. **Test at all widths** -- drag the browser from 320px to 2560px; there should be no "broken" widths.
39
40## Core Capabilities
41
42| Domain | Technologies | Key Patterns |
43|--------|-------------|--------------|
44| Page Layout | CSS Grid, `grid-template-areas` | Named areas, auto-fill, minmax() |
45| Component Layout | Flexbox, CSS Grid | Intrinsic sizing, gap, align/justify |
46| Fluid Sizing | `clamp()`, `min()`, `max()`, viewport units | Smooth scaling without breakpoints |
47| Container Queries | `@container`, `container-type` | Component-intrinsic responsiveness |
48| Fluid Typography | `clamp()` on `font-size`, `line-height` | Readable text at every viewport width |
49| Breakpoint Strategy | Mobile-first `min-width`, Tailwind `sm:md:lg:` | Additive complexity approach |
50
51## Architecture Patterns
52
53### Pattern 1: CSS Grid Page Shell
54
55```css
56.app-shell {
57 display: grid;
58 min-height: 100dvh;
59 grid-template-areas:
60 "header"
61 "main"
62 "footer";
63 grid-template-rows: auto 1fr auto;
64}
65
66@media (min-width: 768px) {
67 .app-shell {
68 grid-template-areas:
69 "header header"
70 "sidebar main"
71 "footer footer";
72 grid-template-columns: 280px 1fr;
73 grid-template-rows: auto 1fr auto;
74 }
75}
76
77@media (min-width: 1280px) {
78 .app-shell {
79 grid-template-areas:
80 "header header header"
81 "sidebar main aside"
82 "footer footer footer";
83 grid-template-columns: 280px 1fr 320px;
84 }
85}
86
87.header { grid-area: header; }
88.sidebar { grid-area: sidebar; }
89.main { grid-area: main; }
90.aside { grid-area: aside; }
91.footer { grid-area: footer; }
92```
93
94```
95 320px (mobile) 768px (tablet) 1280px+ (desktop)
96 ┌──────────────┐ ┌───────────────────┐ ┌──────────────────────┐
97 │ header │ │ header │ │ header │
98 ├──────────────┤ ├──────┬────────────┤ ├──────┬────────┬──────┤
99 │ │ │ side │ │ │ side │ │ aside│
100 │ main │ │ bar │ main │ │ bar │ main │ │
101 │ │ │ │ │ │ │ │ │
102 ├──────────────┤ ├──────┴────────────┤ ├──────┴────────┴──────┤
103 │ footer │ │ footer │ │ footer │
104 └──────────────┘ └───────────────────┘ └──────────────────────┘
105```
106
107### Pattern 2: Fluid Typography System
108
109```css
110:root {
111 /* Fluid type scale: min @ 320px → max @ 1280px */
112 --text-sm: clamp(0.8rem, 0.74rem + 0.3vw, 0.875rem);
113 --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
114 --text-lg: clamp(1.125rem, 0.95rem + 0.85vw, 1.5rem);
115 --text-xl: clamp(1.25rem, 0.9rem + 1.7vw, 2rem);
116 --text-2xl: clamp(1.5rem, 0.8rem + 3.3vw, 3rem);
117 --text-3xl: clamp(2rem, 0.7rem + 5vw, 4rem);
118
119 /* Fluid spacing */
120 --space-sm: clamp(0.5rem, 0.3rem + 1vw, 1rem);
121 --space-md: clamp(1rem, 0.5rem + 2vw, 2rem);
122 --space-lg: clamp(1.5rem, 0.5rem + 4vw, 4rem);
123 --space-xl: clamp(2rem, 0.5rem + 6vw, 6rem);
124}
125
126body { font-size: var(--text-base); }
127h1 { font-size: var(--text-3xl); }
128h2 { font-size: var(--text-2xl); }
129h3 { font-size: var(--text-xl); }
130```
131
132### Pattern 3: Auto-Fill Grid for Card Layouts
133
134```css
135/* Cards auto-fill available space: minimum 280px, expand to fill */
136.card-grid {
137 display: grid;
138 grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
139 gap: var(--space-md);
140}
141```
142
143This single rule handles 1-column (mobile), 2-column (tablet), 3-column (desktop), and 4-column (wide) without any media queries.
144
145## Anti-Patterns
146
1471. **Max-width media queries (desktop-first)** -- `@media (max-width: 768px)` leads to overriding desktop styles for mobile. Use `min-width` (mobile-first) so complexity is added, not subtracted.
1482. **Fixed pixel breakpoints without fluid behavior** -- layout jumps from 1-column to 3-column with no transition. Use `clamp()` and `auto-fill`/`auto-fit` for smooth adaptation.
1493. **`100vw` causing horizontal scroll** -- `100vw` includes the scrollbar width. Use `100%` or `100dvw` for the content area width.
1504. **Viewport media queries for components in variable containers** -- a card in a sidebar is 300px wide even on a 1920px screen. Use `@container` queries for component-level responsiveness.
1515. **Hardcoded heights** -- `height: 600px` on a container overflows on small screens. Use `min-height` or let content determine height.
152
153## Quality Checklist
154
155- [ ] Layout works from 320px to 2560px with no horizontal scroll
156- [ ] Mobile-first approach (base styles = mobile, `min-width` media queries add complexity)
157- [ ] Fluid typography uses `clamp()` for smooth scaling (no text size jumps)
158- [ ] Fluid spacing uses `clamp()` for padding/margins/gaps
159- [ ] `grid-template-areas` used for main page shell (readable and maintainable)
160- [ ] Card/grid layouts use `auto-fill`/`minmax()` (no hardcoded column counts)
161- [ ] Components in variable-width containers use `@container` queries
162- [ ] No `100vw` that could cause horizontal scrollbar overflow
163- [ ] `min-height: 100dvh` used instead of `100vh` (mobile browser chrome safe)
164- [ ] Touch targets are 44x44px minimum on mobile (WCAG 2.2 Target Size)
165- [ ] Layout tested at 320, 375, 768, 1024, 1280, 1920px widths