# Page Template Guide
A consistent, reusable page layout system for all pages in the application.
## Features
- ✅ **Consistent Layout**: Left rail + sidebar + main content area
- ✅ **Responsive Design**: Works on all screen sizes
- ✅ **Sidebar Navigation**: Built-in support for left sidebar with active states
- ✅ **Hero Section**: Optional hero banner with icon, title, description, and actions
- ✅ **Utility Components**: Pre-built sections, cards, grids, and empty states
- ✅ **Type-safe**: Full TypeScript support
---
## Basic Usage
```tsx
import { PageTemplate } from "@/components/layout/page-template";
import { Home } from "lucide-react";
export default function MyPage() {
return (
Your page content here
);
}
```
---
## With Sidebar Navigation
```tsx
import { PageTemplate } from "@/components/layout/page-template";
import { Home, Settings, Users } from "lucide-react";
export default function MyPage() {
return (
Footer content
,
}}
hero={{
icon: Home,
title: "My Page",
description: "Page description",
actions: [
{
label: "Create New",
onClick: () => console.log("Create"),
icon: Plus,
},
],
}}
>
Your content
);
}
```
---
## Using Utility Components
### PageSection
Organized content sections with optional titles and actions:
```tsx
import { PageSection } from "@/components/layout/page-template";
import { Button } from "@/components/ui/button";
View All}
>
Section content
```
### PageCard
Styled cards with consistent padding and hover effects:
```tsx
import { PageCard } from "@/components/layout/page-template";
Card Title
Card content
```
### PageGrid
Responsive grid layouts:
```tsx
import { PageGrid } from "@/components/layout/page-template";
Item 1
Item 2
Item 3
```
### PageEmptyState
Empty states with icon, title, description, and action:
```tsx
import { PageEmptyState } from "@/components/layout/page-template";
import { Inbox } from "lucide-react";
console.log("Create message"),
icon: Plus,
}}
/>
```
---
## Complete Example
Here's a full example combining all components:
```tsx
"use client";
import { useParams } from "next/navigation";
import { Home, Settings, Users, Plus, Mail } from "lucide-react";
import {
PageTemplate,
PageSection,
PageCard,
PageGrid,
PageEmptyState,
} from "@/components/layout/page-template";
export default function DashboardPage() {
const params = useParams();
const workspace = params.workspace as string;
const projectId = params.projectId as string;
return (
Last updated 5 minutes ago
),
}}
hero={{
icon: Home,
title: "Dashboard",
description: "Welcome back! Here's what's happening.",
actions: [
{
label: "Create Report",
onClick: () => console.log("Create report"),
icon: Plus,
},
],
}}
>
{/* Stats Grid */}
Total Users
1,234
Active Sessions
89
Revenue
$12,345
Conversion
3.2%
{/* Recent Activity */}
User signed up
2 minutes ago
{/* Empty State Example */}
console.log("Send"),
icon: Plus,
}}
/>
);
}
```
---
## Props Reference
### PageTemplate
| Prop | Type | Description |
|------|------|-------------|
| `children` | `ReactNode` | Main content |
| `sidebar` | `object` | Optional sidebar configuration |
| `hero` | `object` | Optional hero section configuration |
| `containerWidth` | `"default" \| "wide" \| "full"` | Content container width (default: "default") |
| `className` | `string` | Custom wrapper class |
| `contentClassName` | `string` | Custom content class |
### Sidebar Config
| Prop | Type | Description |
|------|------|-------------|
| `title` | `string` | Sidebar title |
| `description` | `string` | Optional subtitle |
| `items` | `array` | Navigation items |
| `footer` | `ReactNode` | Optional footer content |
### Hero Config
| Prop | Type | Description |
|------|------|-------------|
| `icon` | `LucideIcon` | Optional icon |
| `title` | `string` | Page title |
| `description` | `string` | Optional description |
| `actions` | `array` | Optional action buttons |
---
## Tips
1. **Consistent Icons**: Always use Lucide icons for consistency
2. **Active States**: Pass `isActive` to sidebar items to highlight current page
3. **Responsive**: Grid and card components are responsive by default
4. **Accessibility**: All components include proper ARIA attributes
5. **Performance**: Use "use client" only when you need client-side interactivity
---
## Migration Guide
To migrate an existing page:
1. Import `PageTemplate` and utility components
2. Wrap content in ``
3. Move navigation to `sidebar` prop
4. Move page header to `hero` prop
5. Replace div sections with ``
6. Replace card divs with ``
7. Use `` for responsive grids
Before:
```tsx
{/* sidebar */}
{/* content */}
```
After:
```tsx
{/* content */}
```