skills/frontend-design/layout-system/SKILL.md
Master responsive layout design using modern CSS (Flexbox, Grid), mobile-first approach, and breakpoint strategies. Create layouts that adapt beautifully across all devices while maintaining accessibility and performance. Includes container queries, aspect ratios, and advanced responsive patterns.
npx skillsauth add sanky369/vibe-building-skills layout-systemInstall 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.
Layout is the skeleton of your interface. It determines how content is organized, how users navigate, and how the experience adapts across devices. A well-designed layout system is invisible—users don't notice it because it works so well.
This skill teaches you to think about layout systematically, using modern CSS techniques (Flexbox, Grid, Container Queries) and a mobile-first approach that ensures your product works beautifully everywhere.
The mobile-first approach is not just about making things smaller on mobile. It's a fundamental shift in thinking: start with the simplest, most constrained context (mobile), then progressively enhance for larger screens.
Step 1: Design for Mobile (320px - 480px)
Step 2: Enhance for Tablet (481px - 768px)
Step 3: Optimize for Desktop (769px - 1024px)
Step 4: Maximize for Wide Screens (1025px+)
Flexbox is perfect for layouts that flow in one direction (row or column). Use it for:
Key Flexbox Properties:
flex-direction — row (default) or columnjustify-content — Align items along the main axis (space-between, space-around, center, flex-start, flex-end)align-items — Align items along the cross axis (center, flex-start, flex-end, stretch)gap — Space between itemsflex-wrap — Wrap items to next line if neededflex — Shorthand for flex-grow, flex-shrink, flex-basisExample: Responsive Navigation
/* Mobile: Vertical stack */
nav {
display: flex;
flex-direction: column;
gap: 1rem;
}
/* Tablet and up: Horizontal */
@media (min-width: 768px) {
nav {
flex-direction: row;
justify-content: space-between;
align-items: center;
}
}
Grid is perfect for layouts that need to align in both rows and columns. Use it for:
Key Grid Properties:
grid-template-columns — Define column sizesgrid-template-rows — Define row sizesgap — Space between itemsgrid-auto-flow — How items flow (row or column)grid-column / grid-row — Position items in the gridgrid-template-areas — Named grid areas for semantic layoutsExample: Responsive Page Layout
/* Mobile: Single column */
body {
display: grid;
grid-template-columns: 1fr;
grid-template-areas:
"header"
"main"
"footer";
gap: 1rem;
}
/* Tablet and up: Sidebar + main */
@media (min-width: 768px) {
body {
grid-template-columns: 250px 1fr;
grid-template-areas:
"header header"
"sidebar main"
"footer footer";
}
}
/* Desktop: Sidebar + main + secondary */
@media (min-width: 1024px) {
body {
grid-template-columns: 250px 1fr 300px;
grid-template-areas:
"header header header"
"sidebar main secondary"
"footer footer footer";
}
}
Container queries allow components to respond to their container's size, not the viewport size. This is powerful for reusable components.
Example: Responsive Card
/* Define a container context */
.card-container {
container-type: inline-size;
}
/* Card responds to its container, not the viewport */
.card {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
}
/* When container is wider than 400px, use 2 columns */
@container (min-width: 400px) {
.card {
grid-template-columns: 1fr 1fr;
}
}
Use aspect-ratio to maintain consistent proportions for images, videos, and other media.
/* 16:9 aspect ratio (video) */
.video-container {
aspect-ratio: 16 / 9;
width: 100%;
}
/* 1:1 aspect ratio (square) */
.image-square {
aspect-ratio: 1;
width: 100%;
object-fit: cover;
}
/* 4:3 aspect ratio (photo) */
.image-photo {
aspect-ratio: 4 / 3;
width: 100%;
object-fit: cover;
}
Define breakpoints based on your content, not device sizes. Common breakpoints:
| Breakpoint | Size | Context | Use Case | | :--- | :--- | :--- | :--- | | xs | 320px - 480px | Small mobile | Single column, simplified | | sm | 481px - 640px | Large mobile | Still mostly single column | | md | 641px - 768px | Tablet (portrait) | Two columns possible | | lg | 769px - 1024px | Tablet (landscape) / Small desktop | Three columns possible | | xl | 1025px - 1280px | Desktop | Full layout | | 2xl | 1281px+ | Large desktop | Maximum width containers |
Tailwind CSS Breakpoints:
module.exports = {
theme: {
screens: {
'xs': '320px',
'sm': '640px',
'md': '768px',
'lg': '1024px',
'xl': '1280px',
'2xl': '1536px',
},
},
};
<section class="hero">
<div class="hero-content">
<h1>Welcome</h1>
<p>Your tagline here</p>
<button>Get Started</button>
</div>
<div class="hero-image">
<img src="hero.jpg" alt="Hero" />
</div>
</section>
/* Mobile: Single column, image below text */
.hero {
display: grid;
grid-template-columns: 1fr;
gap: 2rem;
padding: 2rem 1rem;
}
/* Tablet and up: Two columns, image beside text */
@media (min-width: 768px) {
.hero {
grid-template-columns: 1fr 1fr;
gap: 4rem;
padding: 4rem 2rem;
align-items: center;
}
}
<div class="card-grid">
<div class="card"><!-- content --></div>
<div class="card"><!-- content --></div>
<div class="card"><!-- content --></div>
</div>
/* Mobile: 1 column */
.card-grid {
display: grid;
grid-template-columns: 1fr;
gap: 1.5rem;
}
/* Tablet: 2 columns */
@media (min-width: 768px) {
.card-grid {
grid-template-columns: repeat(2, 1fr);
}
}
/* Desktop: 3 columns */
@media (min-width: 1024px) {
.card-grid {
grid-template-columns: repeat(3, 1fr);
}
}
<div class="layout">
<aside class="sidebar"><!-- navigation --></aside>
<main class="main"><!-- content --></main>
</div>
/* Mobile: Stacked */
.layout {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
}
/* Tablet and up: Sidebar beside main */
@media (min-width: 768px) {
.layout {
grid-template-columns: 250px 1fr;
gap: 2rem;
}
.sidebar {
position: sticky;
top: 0;
height: fit-content;
}
}
/* Mobile: Smaller text */
h1 {
font-size: 24px;
line-height: 1.2;
}
/* Tablet: Medium text */
@media (min-width: 768px) {
h1 {
font-size: 32px;
}
}
/* Desktop: Larger text */
@media (min-width: 1024px) {
h1 {
font-size: 40px;
}
}
/* Or use fluid typography */
h1 {
font-size: clamp(24px, 5vw, 40px);
}
Ensure interactive elements are at least 44x44px (WCAG 2.5.5 Level AAA):
button, a, input {
min-width: 44px;
min-height: 44px;
padding: 0.75rem 1rem; /* Adjust as needed */
}
Optimal line length is 50-75 characters. Use max-width to constrain text:
main {
max-width: 65ch; /* ~65 characters */
margin: 0 auto;
padding: 0 1rem;
}
Generous whitespace improves readability and reduces cognitive load:
section {
padding: 2rem 1rem; /* Mobile */
}
@media (min-width: 768px) {
section {
padding: 4rem 2rem; /* Tablet */
}
}
@media (min-width: 1024px) {
section {
padding: 6rem 4rem; /* Desktop */
}
}
Ensure keyboard navigation follows a logical order:
/* Use flexbox or grid order property to reorder visually without affecting tab order */
.item {
order: 1; /* Visual order, doesn't affect tab order */
}
/* For tab order, use HTML source order or tabindex (use sparingly) */
"I'm using the layout-system skill. Can you audit my current layouts?
- Analyze my responsive behavior
- Check for accessibility issues (touch targets, line length, whitespace)
- Identify layouts that don't work well on mobile
- Suggest improvements"
"Can you create responsive layouts for:
- Hero section (mobile-first)
- Card grid (1 column mobile, 2 tablet, 3 desktop)
- Sidebar + main content
- Navigation bar (hamburger on mobile, horizontal on desktop)
- Footer"
"Can you help me implement container queries for my card component?
- Define container context
- Create responsive card layout based on container width
- Ensure accessibility"
"Can you create a responsive testing checklist?
- Mobile (320px, 480px)
- Tablet (768px)
- Desktop (1024px, 1280px)
- What to check at each breakpoint"
Claude Code can critique your layouts:
"Can you evaluate my layouts?
- Are they truly mobile-first?
- Are touch targets large enough?
- Is the reading line length appropriate?
- Is there enough whitespace?
- Do they work well at all breakpoints?
- Are there any accessibility issues?"
1. Mobile-First is a Mindset Start simple, progressively enhance. This results in better products for everyone.
2. Content Determines Breakpoints Don't use arbitrary breakpoints. Use breakpoints where your content needs them.
3. Whitespace is Content Generous whitespace improves readability and reduces cognitive load.
4. Flexibility Over Rigidity Use flexible units (%, em, rem) instead of fixed pixels. This allows your layout to adapt.
5. Test on Real Devices Emulators are helpful, but test on real devices. Real network conditions, real touch, real performance.
A well-designed layout system is the foundation of a great experience across all devices.
testing
Diagnose your marketing situation and sequence all 9 other skills strategically. Use when starting a new marketing initiative, auditing your current system, or optimizing your marketing strategy.
development
Use when creating an original visual design language, identity, or art direction for any artifact — infographics, video storyboards, websites, or mobile app UI/UX — or when a design feels generic, derivative, "AI-default," or inconsistent and needs one unifying idea. Triggers on "design language", "art direction", "make it original", "visual identity", "looks generic", "design a world".
development
Write viral, persuasive, engaging tweets and threads. Uses web research to find viral examples in your niche, then models writing based on proven formulas and X algorithm optimization. Use when creating tweets, threads, or X content strategy.
development
Complete DIY SEO strategy based on agency secrets. Covers winnable keyword research, programmatic content at scale, link building, technical SEO, and 90-day action plans. Reference the Complete_SEO_Playbook.md in references folder for deep dives.