Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
One-time setup that gathers your project's design context and saves it to CLAUDE.md for future sessions.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
reference/responsive-design.md
1# Responsive Design23## Mobile-First: Write It Right45Start with base styles for mobile, use `min-width` queries to layer complexity. Desktop-first (`max-width`) means mobile loads unnecessary styles first.67## Breakpoints: Content-Driven89Don't chase device sizes; let content tell you where to break. Start narrow, stretch until design breaks, add breakpoint there. Three breakpoints usually suffice (640, 768, 1024px). Use `clamp()` for fluid values without breakpoints.1011## Detect Input Method, Not Just Screen Size1213**Screen size doesn't tell you input method.** A laptop with touchscreen, a tablet with keyboard. Use pointer and hover queries:1415```css16/* Fine pointer (mouse, trackpad) */17@media (pointer: fine) {18.button { padding: 8px 16px; }19}2021/* Coarse pointer (touch, stylus) */22@media (pointer: coarse) {23.button { padding: 12px 20px; } /* Larger touch target */24}2526/* Device supports hover */27@media (hover: hover) {28.card:hover { transform: translateY(-2px); }29}3031/* Device doesn't support hover (touch) */32@media (hover: none) {33.card { /* No hover state - use active instead */ }34}35```3637**Critical**: Don't rely on hover for functionality. Touch users can't hover.3839## Safe Areas: Handle the Notch4041Modern phones have notches, rounded corners, and home indicators. Use `env()`:4243```css44body {45padding-top: env(safe-area-inset-top);46padding-bottom: env(safe-area-inset-bottom);47padding-left: env(safe-area-inset-left);48padding-right: env(safe-area-inset-right);49}5051/* With fallback */52.footer {53padding-bottom: max(1rem, env(safe-area-inset-bottom));54}55```5657**Enable viewport-fit** in your meta tag:58```html59<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">60```6162## Responsive Images: Get It Right6364### srcset with Width Descriptors6566```html67<img68src="hero-800.jpg"69srcset="70hero-400.jpg 400w,71hero-800.jpg 800w,72hero-1200.jpg 1200w73"74sizes="(max-width: 768px) 100vw, 50vw"75alt="Hero image"76>77```7879**How it works**:80- `srcset` lists available images with their actual widths (`w` descriptors)81- `sizes` tells the browser how wide the image will display82- Browser picks the best file based on viewport width AND device pixel ratio8384### Picture Element for Art Direction8586When you need different crops/compositions (not just resolutions):8788```html89<picture>90<source media="(min-width: 768px)" srcset="wide.jpg">91<source media="(max-width: 767px)" srcset="tall.jpg">92<img src="fallback.jpg" alt="...">93</picture>94```9596## Layout Adaptation Patterns9798**Navigation**: Three stages: hamburger + drawer on mobile, horizontal compact on tablet, full with labels on desktop. **Tables**: Transform to cards on mobile using `display: block` and `data-label` attributes. **Progressive disclosure**: Use `<details>/<summary>` for content that can collapse on mobile.99100## Testing: Don't Trust DevTools Alone101102DevTools device emulation is useful for layout but misses:103104- Actual touch interactions105- Real CPU/memory constraints106- Network latency patterns107- Font rendering differences108- Browser chrome/keyboard appearances109110**Test on at least**: One real iPhone, one real Android, a tablet if relevant. Cheap Android phones reveal performance issues you'll never see on simulators.111112---113114**Avoid**: Desktop-first design. Device detection instead of feature detection. Separate mobile/desktop codebases. Ignoring tablet and landscape. Assuming all mobile devices are powerful.115