---
name: responsive-layout
description: Create responsive layouts with Tailwind CSS including sidebar navigation, dashboard grids, and mobile-first design. Use when you need to build page layouts, dashboards, responsive grids, or navigation structures.
version: 1.0.0
author: Maestro
---
# Responsive Layout
Build mobile-first responsive layouts using Tailwind CSS with sidebar navigation, dashboard grids, and adaptive content areas.
## When to Use
- User needs to create a page layout with sidebar and header
- User wants to build a responsive dashboard with metric cards
- User needs a mobile-first grid that adapts to screen sizes
- User wants to add responsive navigation (sidebar + mobile menu)
- User needs to structure a page with proper spacing and overflow handling
## Available Operations
1. Create a full app layout (sidebar + header + main content)
2. Build responsive dashboard grids with metric cards
3. Implement collapsible sidebar with mobile drawer
4. Set up responsive content grids
5. Add proper scroll areas and overflow handling
## Multi-Step Workflow
### Step 1: Install Dependencies
```bash
npm install clsx tailwind-merge lucide-react
```
Verify Tailwind is configured:
```bash
npx tailwindcss --help
# If not installed: npm install -D tailwindcss postcss autoprefixer && npx tailwindcss init -p
```
### Step 2: Create the App Shell Layout
```tsx
// src/layouts/AppLayout.tsx
import { useAppStore } from '@/stores/useAppStore';
export function AppLayout({ children }: { children: React.ReactNode }) {
const sidebarOpen = useAppStore((s) => s.sidebarOpen);
return (
{/* Sidebar */}
{/* Main area */}
{children}
);
}
```
### Step 3: Build the Sidebar
```tsx
// src/components/Sidebar.tsx
import { NavLink } from 'react-router-dom';
import { Home, List, Users, Settings, X } from 'lucide-react';
import { useAppStore } from '@/stores/useAppStore';
const navItems = [
{ to: '/dashboard', label: 'Dashboard', icon: Home },
{ to: '/items', label: 'Items', icon: List },
{ to: '/team', label: 'Team', icon: Users },
{ to: '/settings', label: 'Settings', icon: Settings },
];
export function Sidebar({ open }: { open: boolean }) {
const toggleSidebar = useAppStore((s) => s.toggleSidebar);
return (
<>
{/* Mobile overlay */}
{open && (
)}
{/* Sidebar */}
>
);
}
```
### Step 4: Build a Dashboard Grid
```tsx
// src/pages/Dashboard.tsx
import { Activity, Users, Shield, CheckCircle } from 'lucide-react';
export function Dashboard() {
return (
);
}
```
### Step 5: Verify Responsive Behavior
```bash
npm run dev
# Open http://localhost:5173
# Test responsive breakpoints:
# 1. Resize browser window through breakpoints (640px, 768px, 1024px, 1280px)
# 2. Use browser DevTools device toolbar (Ctrl+Shift+M / Cmd+Shift+M)
# 3. Check sidebar collapses on mobile and shows overlay
# 4. Check grid columns adjust at each breakpoint
```
## Resources
- `references/breakpoint-guide.md` - Tailwind breakpoints and responsive patterns
## Examples
### Example 1: Create a Dashboard Layout
User asks: "Build a dashboard page with stats cards and an activity feed"
Response approach:
1. Create AppLayout with sidebar and header
2. Build MetricCard component for stats
3. Use responsive grid: 1->2->4 columns
4. Add two-column section for feed + sidebar content
5. Test at all breakpoints with `npm run dev`
### Example 2: Add Mobile Navigation
User asks: "Make the sidebar work on mobile devices"
Response approach:
1. Make sidebar fixed/absolute on mobile with transform transition
2. Add overlay backdrop that closes sidebar on tap
3. Add hamburger menu button in Header (visible only on mobile: `lg:hidden`)
4. Connect to Zustand toggleSidebar action
5. Test on mobile viewport in DevTools
## Notes
- Always design mobile-first: write base styles for mobile, then add `sm:`, `md:`, `lg:` overrides
- Use `overflow-hidden` on the app shell and `overflow-y-auto` on scrollable content areas
- Use `fixed` positioning for mobile sidebar/drawer, `static` for desktop
- Add `transition-transform` for smooth sidebar open/close animations
- Test at every Tailwind breakpoint: 640px, 768px, 1024px, 1280px