Design · Skill

Build responsive layouts

build-responsive-layouts

Builds page layouts that hold up on every screen size using mobile-first CSS, content-based breakpoints, fluid type with clamp, and container queries. Use when a layout overflows on a phone, the user wants a responsive layout, fluid typography, or container queries.

Works with: Any AI Not yet model-tested; testing Jan 2027

Paste it into ChatGPT, Claude, Gemini or any AI chat, then tell it about your project. How it works

Install in Claude Code, Cursor or Codex (optional)

Only for AI coding tools that read skill folders. Run one line in a terminal, in your project folder. It downloads this skill's text files from TheSkillVault and nothing else; you can read them first with “View raw SKILL.md”.

Claude Code (all your projects)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-responsive-layouts/raw' -o ~/'.claude/skills/build-responsive-layouts/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-responsive-layouts/files/LICENSE.txt' -o ~/'.claude/skills/build-responsive-layouts/LICENSE.txt'

Cursor (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-responsive-layouts/raw' -o '.cursor/skills/build-responsive-layouts/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-responsive-layouts/files/LICENSE.txt' -o '.cursor/skills/build-responsive-layouts/LICENSE.txt'

Codex and other Agent Skills tools (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-responsive-layouts/raw' -o '.agents/skills/build-responsive-layouts/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/build-responsive-layouts/files/LICENSE.txt' -o '.agents/skills/build-responsive-layouts/LICENSE.txt'

Or connect the whole library over MCP

Add TheSkillVault to Cursor or add this to your app's MCP settings (read-only; help):

{
  "mcpServers": {
    "theskillvault": {
      "url": "https://theskillvault.ai/mcp"
    }
  }
}

A layout should be readable on a phone and comfortable on a wide screen. Start from the narrow screen. Add rules only when the content needs more room.

When to use

  • A page scrolls sideways on a phone, or text is cut off.
  • A card or nav should change when its own box gets wider, not only when the window does.
  • Type and spacing jump between two fixed sizes instead of scaling smoothly.

When not to use

  • You only need colour, font and spacing tokens for a theme. That is a separate task.
  • The job is a one-off hero headline, not the page layout.

Steps

  1. Write the CSS for the narrow screen first. No media query yet. The column is a single stack, with padding on the page, not a fixed pixel width.
  2. Let type and space scale between a minimum and a maximum. clamp(1rem, 0.9rem + 1vw, 1.35rem) is enough for body text. Do not use a raw vw size with no floor or ceiling.
  3. Add a breakpoint only where the content breaks. A common place is when two columns fit without squeezing. Prefer min-width queries so the wide rules enhance the mobile base.
  4. For a component that is reused in a sidebar and in a full page, set container-type: inline-size on the parent. Style the inside with @container, not with the viewport.
  5. Give images a max width of 100% and a set aspect-ratio, so they do not stretch or blow the column out.
  6. Check tap targets. Buttons and links need about 44 by 44 pixels of hit area on touch screens.
  7. Resize the browser from 320px to a wide desktop. Fix any horizontal scrollbar before you call it done. Check a real phone if you can. A simulator misses some browser chrome.
.card-wrap { container-type: inline-size; }
.card { display: grid; gap: 0.75rem; }
@container (min-width: 28rem) {
  .card { grid-template-columns: 8rem 1fr; align-items: center; }
}

Gotchas

  • 100vh is taller than the visible area on many phones. Use dvh or svh for full-height panels.
  • A wide table or a long word with no break will force sideways scroll. Allow wrap, or let the table scroll inside its own box.
  • Fixed widths in pixels fight the fluid layout. Prefer max-width, minmax and %.
  • Do not put private screenshots, customer photos or tokens in a public demo of the layout.

Portability

The CSS works in current browsers. If you use Tailwind, map the same idea onto min-width screens and @container. If you use another framework, keep the mobile-first order and the container query. Older browsers that lack container queries still get the stacked layout.

Done when

  • At 320px there is no horizontal page scroll.
  • Type stays readable, and a repeated component changes with its container.
  • Tap targets are large enough to hit with a thumb.

Example prompt

"This product grid overflows on a phone. Make it one column on small screens, two when the container is wide, with fluid headings."

---

Adapted from "responsive-design" in wshobson/agents (MIT, Copyright (c) 2024 Seth Hobson). See LICENSE.txt.

Bundled files

Licence

Adapted from Seth Hobson (wshobson/agents, responsive-design) (Copyright (c) 2024 Seth Hobson), MIT License. Adapted by TheSkillVault: rewritten as a short build order (mobile base, fluid type, container queries, overflow checks) with one original example; dropped the breakpoint catalogue and reference files; added gotchas and done-when.

Licence: MIT License. Attribution when you reuse it: Based on work by Seth Hobson (wshobson/agents, responsive-design) (Copyright (c) 2024 Seth Hobson, MIT License), https://github.com/wshobson/agents/tree/7e2fb559cf4b824b27f1fec49fe88f7511066d26/plugins/ui-design/skills/responsive-design; adapted by TheSkillVault, https://theskillvault.ai