/**
* Layout Patterns Demo
* Interactive demonstrations of essential layout patterns
* Access: /dev/layouts
*/
import type { Metadata } from 'next';
import { Link } from '@/lib/i18n/routing';
import { Grid3x3 } from 'lucide-react';
import { DevBreadcrumbs } from '@/components/dev/DevBreadcrumbs';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Example, ExampleSection } from '@/components/dev/Example';
import { BeforeAfter } from '@/components/dev/BeforeAfter';
export const metadata: Metadata = {
title: 'Layout Patterns | Dev',
description: 'Essential layout patterns with before/after examples',
};
export default function LayoutsPage() {
return (
{/* Breadcrumbs */}
{/* Content */}
{/* Introduction */}
These 5 essential layout patterns cover 80% of interface needs. Each pattern includes
live examples, before/after comparisons, and copy-paste code.
Grid vs Flex
Responsive
Mobile-first
Best practices
{/* 1. Page Container */}
Page Title
Content Card
Your main content goes here.
`}
>
Page Title
Content Card
Constrained to max-w-4xl for readability
Your main content goes here. The max-w-4xl constraint ensures comfortable
reading width.
Full Width Content
This text spans the entire width, making it hard to read on large screens.
Lines become too long.
),
}}
after={{
caption: 'Constrained with max-w for better readability',
content: (
Constrained Content
This text has a max-width, creating comfortable line lengths for reading.
),
}}
/>
{/* 2. Dashboard Grid */}
{items.map(item => (
{item.title}
{item.content}
))}
`}
>
{[1, 2, 3, 4, 5, 6].map((i) => (
Metric {i}
{(Math.random() * 1000).toFixed(0)}
+{(Math.random() * 20).toFixed(1)}% from last month
))}
),
}}
after={{
caption: 'grid with grid-cols - consistent sizing',
content: (
),
}}
/>
{/* 3. Form Layout */}
Login
Enter your credentials
`}
>
Login
Enter your credentials to continue
{/* 4. Sidebar Layout */}
{/* 5. Centered Content */}
Centered Card
Content perfectly centered on screen.
`}
>
Centered Card
Centered vertically and horizontally
Perfect for login screens, error pages, and loading states.
{/* Decision Tree */}
Grid vs Flex Quick Guide
Use Grid
When you need...
- Equal-width columns (dashboard cards)
- 2D layout (rows AND columns)
- Consistent grid structure
- Auto-fill/auto-fit responsive grids
grid grid-cols-3 gap-6
Use Flex
When you need...
- Variable-width items (buttons, tags)
- 1D layout (row OR column)
- Center alignment
- Space-between/around distribution
flex gap-4 items-center
{/* Responsive Patterns */}
1 → 2 → 3 Progression
Most common pattern
grid-cols-1 md:grid-cols-2 lg:grid-cols-3
Mobile: 1 column
Tablet: 2 columns
Desktop: 3 columns
1 → 2 → 4 Progression
For smaller cards
grid-cols-1 md:grid-cols-2 lg:grid-cols-4
Mobile: 1 column
Tablet: 2 columns
Desktop: 4 columns
Stack → Row
Form buttons, toolbars
flex flex-col sm:flex-row
Mobile: Stacked vertically
Tablet+: Horizontal row
Hide Sidebar
Mobile navigation
hidden lg:block
Mobile: Hidden (use menu)
Desktop: Visible sidebar
{/* Footer */}
);
}