responsive-design/SKILL.md
Mobile-first responsive design standards covering content-driven breakpoints, container queries, pointer/hover detection, safe areas, responsive images, layout adaptation patterns, and real-device testing. Cross-platform web skill. Based on...
npx skillsauth add peterbamuhigire/skills-web-dev responsive-designInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
responsive-design or would be better handled by a more specific companion skill.SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.| Companion Skill | When to Load |
|---|---|
| practical-ui-design | Visual system (colour, type, spacing) |
| webapp-gui-design | Web app-specific implementations |
| form-ux-design | Responsive form patterns |
| frontend-performance | Image and loading optimisation |
| ai-slop-prevention | Avoid generic responsive templates |
Write base CSS for the smallest screen. Add complexity with min-width media queries.
/* Base: mobile */
.layout { display: flex; flex-direction: column; gap: var(--space-md); }
/* Tablet and up */
@media (min-width: 768px) {
.layout { flex-direction: row; }
}
/* Desktop */
@media (min-width: 1200px) {
.layout { max-width: 1200px; margin-inline: auto; }
}
min-width) is easier than removing it (max-width)max-width Queriesmax-width queries indicate desktop-first thinking. Refactor to min-width.
There are too many screen sizes to target specific devices. Instead, let content determine where the layout breaks.
Most designs need only three breakpoints:
| Name | Typical Range | Purpose | |---|---|---| | Compact | < 600px | Single column, stacked layout | | Medium | 600-1024px | Two columns, side-by-side where appropriate | | Expanded | > 1024px | Full layout, multi-column, sidebars |
min-width query at that exact pixel valueScreen size does NOT tell you about the input device. A 1024px iPad is touch; a 1024px laptop has a mouse.
/* Mouse/trackpad — fine pointer, hover available */
@media (pointer: fine) and (hover: hover) {
.button { padding: 8px 16px; }
.tooltip { display: block; } /* hover tooltips work */
}
/* Touch — coarse pointer, no reliable hover */
@media (pointer: coarse) {
.button { padding: 12px 24px; min-height: 48px; }
.tooltip { display: none; } /* use tap/long-press instead */
}
| Query | Device Type | Design Implication |
|---|---|---|
| pointer: fine + hover: hover | Mouse/trackpad | Hover states, smaller targets OK |
| pointer: coarse + hover: none | Phone/tablet touch | 48px targets, no hover-dependent features |
| pointer: fine + hover: none | Stylus | Fine targets OK, no hover |
| pointer: coarse + hover: hover | Game controller, TV remote | Large targets, hover possible |
Never hide essential functionality behind hover. Touch users cannot hover. Always provide tap/click alternatives.
Modern devices have notches, rounded corners, and dynamic islands that obscure content.
/* Apply safe area padding */
.app-shell {
padding-top: env(safe-area-inset-top);
padding-right: env(safe-area-inset-right);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
}
/* Combine with existing padding */
.bottom-nav {
padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
The viewport-fit=cover enables env(safe-area-inset-*) values.
Media queries respond to the viewport. Container queries respond to the parent container — making components truly reusable regardless of where they're placed.
/* Define a containment context */
.card-container {
container-type: inline-size;
container-name: card;
}
/* Respond to container width, not viewport */
@container card (min-width: 400px) {
.card { display: grid; grid-template-columns: 200px 1fr; }
}
@container card (max-width: 399px) {
.card { display: flex; flex-direction: column; }
}
| Use Container Queries | Use Media Queries | |---|---| | Reusable components (cards, widgets) | Page-level layout | | Sidebar vs main content adaptations | Navigation structure | | Components used in different contexts | Typography scale changes | | Design system components | Global spacing adjustments |
<img
src="photo-800.jpg"
srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1200.jpg 1200w"
sizes="(min-width: 1024px) 33vw, (min-width: 600px) 50vw, 100vw"
alt="Descriptive alt text"
loading="lazy"
decoding="async"
>
<picture><picture>
<source media="(min-width: 1024px)" srcset="hero-wide.jpg">
<source media="(min-width: 600px)" srcset="hero-medium.jpg">
<img src="hero-mobile.jpg" alt="Hero image description">
</picture>
loading="lazy" for below-the-fold imagesloading="eager" for hero/above-the-fold images (LCP)width and height attributes to prevent layout shift (CLS)| Screen | Pattern | |---|---| | Compact (< 600px) | Bottom tab bar (3-5 items) + hamburger for overflow | | Medium (600-1024px) | Compact horizontal nav (icons + labels) or rail | | Expanded (> 1024px) | Full horizontal nav with dropdowns, or sidebar |
/* Desktop: standard table */
.data-table { display: table; }
/* Mobile: stack as cards */
@media (max-width: 599px) {
.data-table, .data-table tbody, .data-table tr, .data-table td {
display: block;
}
.data-table thead { display: none; }
.data-table td::before {
content: attr(data-label);
font-weight: bold;
display: block;
}
}
/* Self-adjusting grid — no media queries needed */
.auto-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
gap: var(--space-md);
}
| Element | Compact | Medium | Expanded | |---|---|---|---| | Primary content | Full width | 2/3 width | Main column | | Secondary content | Below primary | 1/3 width or tabbed | Sidebar | | Tertiary content | Hidden or collapsible | Collapsible | Right panel | | Decorative images | Hidden | Reduced | Full size |
/* Fluid type: scales between 18px (at 320px viewport) and 22px (at 1200px) */
body {
font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
}
/* Fluid heading */
h1 {
font-size: clamp(2rem, 1.5rem + 2vw, 3.5rem);
}
min and max bounds with clamp() — never let text grow/shrink without limitsDevTools device emulation does NOT accurately represent:
| Dimension | Test On | |---|---| | iOS | iPhone SE (small), iPhone 15 (standard), iPad | | Android | Budget phone (e.g., Samsung A series), flagship, tablet | | Desktop | 1366px (common laptop), 1920px (standard), 2560px (wide) | | Input | Mouse, trackpad, touch, keyboard-only | | Browser | Chrome, Safari, Firefox (minimum) | | Orientation | Portrait + landscape on all mobile/tablet | | Zoom | 100%, 150%, 200% |
| Anti-Pattern | Fix |
|---|---|
| Desktop-first with max-width overrides | Rewrite mobile-first with min-width |
| Device-specific breakpoints (320px, 375px, 414px) | Use content-driven breakpoints |
| Hiding content on mobile with display: none | Restructure or use progressive disclosure |
| Hover-only interactions | Add tap/click alternatives |
| Fixed pixel widths for containers | Use %, fr, min(), clamp() |
| Text in images (unscalable) | Use real text with CSS styling |
| Assuming portrait orientation | Test and design for both orientations |
| Ignoring safe areas | Apply env(safe-area-inset-*) |
Sources: Impeccable responsive-design reference (Bakaus, 2025); MDN Web Docs — Responsive Design; Web.dev — Learn Responsive Design.
data-ai
Use when adding AI-powered analytics to a SaaS platform — semantic search over business data, natural language queries, trend detection, anomaly alerts, and AI-generated insights for dashboards. Covers embeddings, NL2SQL, and per-tenant analytics...
data-ai
Design AI-powered analytics dashboards — what metrics to show, how to display AI predictions and confidence, drill-down patterns, KPI cards, trend visualisation, AI Insights panels, export design, and role-based dashboard variants. Invoke when...
development
Use when designing, building, reviewing, or upgrading production software systems that must be secure, performant, maintainable, scalable, and user-centered. Apply before writing specs, code, architecture, APIs, databases, mobile apps, SaaS platforms, or ERP systems.
development
Professional web app UI using commercial templates (Tabler/Bootstrap 5) with strong frontend design direction when needed. Use for CRUD interfaces, dashboards, admin panels with SweetAlert2, DataTables, Flatpickr. Clone seeder-page.php, use...