--- name: dashboard-design description: Design effective dashboards with clear layouts, KPI displays, data grids, and real-time updates. Covers dashboard patterns, information hierarchy, responsive grids, widget design, and admin panel layouts. Use for building analytics dashboards, admin interfaces, and monitoring displays. --- # Dashboard Design Create effective, information-rich dashboards that surface key data clearly. ## Instructions 1. **Prioritize information** - Most important metrics at top-left 2. **Use consistent card layouts** - Same styling for similar data types 3. **Design for scanning** - Users glance, not read; make data obvious 4. **Show context** - Compare to previous periods, show trends 5. **Enable action** - Dashboards should lead to decisions ## Dashboard Layout Patterns ### Standard Admin Dashboard ```tsx function AdminDashboard() { return (
{/* Top Navigation */}
{/* Sidebar Navigation */} {/* Main Content */}
{/* Page Header */}

Dashboard Overview

Welcome back, here's what's happening

{/* KPI Cards Row */}
{/* Charts Row */}
{/* Data Table */} Recent Orders
); } ``` ### KPI Card Component ```tsx interface KPICardProps { title: string; value: string | number; change?: string; trend?: 'up' | 'down' | 'neutral'; icon?: React.ComponentType; subtitle?: string; } function KPICard({ title, value, change, trend, icon: Icon, subtitle }: KPICardProps) { return (

{title}

{value}

{change && (
{trend === 'up' && ( )} {trend === 'down' && ( )} {change} vs last month
)}
{Icon && (
)}
); } ``` ### Chart Card Component ```tsx interface ChartCardProps { title: string; subtitle?: string; action?: React.ReactNode; children: React.ReactNode; } function ChartCard({ title, subtitle, action, children }: ChartCardProps) { return (

{title}

{subtitle && (

{subtitle}

)}
{action}
{children}
); } ``` ## Dashboard Grid Patterns ### Responsive Dashboard Grid ```tsx // 12-column grid system
{/* Full width */}
{/* 4 equal KPI cards */}
{/* 2/3 + 1/3 layout */}
{/* 50/50 split */}
``` ## Real-Time Dashboard ```tsx function RealTimeDashboard() { const [metrics, setMetrics] = useState(null); useEffect(() => { // WebSocket for real-time updates const ws = new WebSocket('wss://api.example.com/metrics'); ws.onmessage = (event) => { const data = JSON.parse(event.data); setMetrics(data); }; return () => ws.close(); }, []); return (
{/* Live indicator */}
Live Updated {formatRelativeTime(metrics?.timestamp)}
{/* Real-time metrics */}
1} />
); } ``` ## Data Table for Dashboards ```tsx interface DataTableProps { columns: ColumnDef[]; data: T[]; pagination?: boolean; searchable?: boolean; actions?: (row: T) => React.ReactNode; } function DataTable({ columns, data, pagination, searchable }: DataTableProps) { const [search, setSearch] = useState(''); const [page, setPage] = useState(1); const pageSize = 10; const filteredData = useMemo(() => { if (!search) return data; return data.filter(row => Object.values(row).some(val => String(val).toLowerCase().includes(search.toLowerCase()) ) ); }, [data, search]); const paginatedData = useMemo(() => { if (!pagination) return filteredData; const start = (page - 1) * pageSize; return filteredData.slice(start, start + pageSize); }, [filteredData, page, pagination]); return (
{searchable && (
setSearch(e.target.value)} className="px-4 py-2 border rounded-lg w-full max-w-sm" />
)}
{columns.map(col => ( ))} {paginatedData.map((row, i) => ( {columns.map(col => ( ))} ))}
{col.header}
{col.render ? col.render(row) : row[col.key]}
{pagination && ( )}
); } ``` ## Best Practices 1. **5-second rule** - Key metrics should be understood in 5 seconds 2. **Above the fold** - Critical data visible without scrolling 3. **Consistent time ranges** - All charts use same time period 4. **Progressive disclosure** - Summary → details on demand 5. **Empty states** - Show meaningful content when no data 6. **Loading states** - Skeleton screens while loading ## When to Use - Building admin panels and back-office tools - Creating analytics dashboards - Monitoring systems and real-time displays - Data-heavy business applications - Internal tools and management interfaces ## Notes - Consider user role - executives vs analysts have different needs - Mobile dashboards need different layouts, not just responsive - Performance matters - virtualize long lists, lazy load charts - Allow customization - users can arrange their own dashboards