<!DOCTYPE html>
<html lang="en" class="h-full">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Admin Dashboard - Sherlock</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
/* Custom chart height */
.chart-container { height: 300px; }
@media (min-width: 1024px) { .chart-container { height: 400px; } }
</style>
</head>
<body class="bg-gray-50 h-full overflow-hidden">
<div class="flex h-full">
<!-- Sidebar -->
<div id="sidebar" class="fixed inset-y-0 left-0 z-50 w-64 bg-white shadow-lg transform -translate-x-full lg:translate-x-0 transition-transform duration-200 ease-in-out border-r border-gray-200">
<!-- Logo -->
<div class="flex items-center justify-center h-16 bg-gradient-to-r from-indigo-600 to-purple-600 text-white">
<h1 class="text-xl font-bold">AdminDash</h1>
</div>
<!-- Navigation -->
<nav class="mt-8 px-4 space-y-2">
<a href="#" class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-gray-100 transition-colors group">
<i class="fas fa-home w-5 mr-3 text-indigo-500 group-hover:text-indigo-600"></i>
Dashboard
</a>
<a href="#" class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-gray-100 transition-colors group">
<i class="fas fa-chart-line w-5 mr-3 text-gray-400 group-hover:text-indigo-500"></i>
Analytics
</a>
<a href="#" class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-gray-100 transition-colors group">
<i class="fas fa-users w-5 mr-3 text-gray-400 group-hover:text-indigo-500"></i>
Users
</a>
<a href="#" class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-gray-100 transition-colors group">
<i class="fas fa-shopping-cart w-5 mr-3 text-gray-400 group-hover:text-indigo-500"></i>
Orders
</a>
<a href="#" class="flex items-center px-4 py-3 text-gray-700 rounded-lg hover:bg-gray-100 transition-colors group">
<i class="fas fa-cog w-5 mr-3 text-gray-400 group-hover:text-indigo-500"></i>
Settings
</a>
</nav>
</div>
<!-- Mobile sidebar overlay -->
<div id="sidebarOverlay" class="fixed inset-0 z-40 bg-black bg-opacity-50 lg:hidden hidden"></div>
<!-- Main Content -->
<div class="flex-1 flex flex-col overflow-hidden lg:ml-0">
<!-- Header -->
<header class="bg-white shadow-sm border-b border-gray-200 px-4 sm:px-6 lg:px-8 py-4 flex items-center justify-between">
<div class="flex items-center">
<button id="toggleSidebarBtn" class="lg:hidden p-2 rounded-lg bg-gray-100 hover:bg-gray-200 transition-colors mr-4">
<i class="fas fa-bars text-gray-600"></i>
</button>
<h2 class="text-2xl font-semibold text-gray-900">Dashboard</h2>
</div>
<div class="flex items-center space-x-4">
<div class="relative">
<input type="text" placeholder="Search..." class="w-64 px-4 py-2 bg-gray-100 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:bg-white">
</div>
<button class="p-2 text-gray-500 hover:text-gray-700 rounded-lg hover:bg-gray-100 transition-colors relative">
<i class="fas fa-bell"></i>
<span class="absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-5 w-5 flex items-center justify-center">3</span>
</button>
<div class="flex items-center space-x-2 p-2 hover:bg-gray-100 rounded-lg cursor-pointer transition-colors">
<img src="https://i.pravatar.cc/32?img=1" alt="User" class="w-8 h-8 rounded-full">
<span class="text-gray-700 font-medium hidden sm:block">Admin User</span>
</div>
</div>
</header>
<!-- Main Content Area -->
<main class="flex-1 overflow-y-auto p-4 sm:p-6 lg:p-8">
<!-- Stats Cards -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<div class="bg-white p-6 rounded-xl shadow-lg border border-gray-100 hover:shadow-xl transition-shadow">
<div class="flex items-center">
<div class="p-3 bg-gradient-to-r from-green-400 to-green-500 rounded-xl">
<i class="fas fa-dollar-sign text-white text-2xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Total Revenue</p>
<p id="revenueStat" class="text-3xl font-bold text-gray-900">$24,392</p>
<span class="text-green-600 text-sm font-medium">+12.4%</span>
</div>
</div>
</div>
<div class="bg-white p-6 rounded-xl shadow-lg border border-gray-100 hover:shadow-xl transition-shadow">
<div class="flex items-center">
<div class="p-3 bg-gradient-to-r from-blue-400 to-blue-500 rounded-xl">
<i class="fas fa-users text-white text-2xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Total Users</p>
<p id="usersStat" class="text-3xl font-bold text-gray-900">1,234</p>
<span class="text-green-600 text-sm font-medium">+8.2%</span>
</div>
</div>
</div>
<div class="bg-white p-6 rounded-xl shadow-lg border border-gray-100 hover:shadow-xl transition-shadow">
<div class="flex items-center">
<div class="p-3 bg-gradient-to-r from-purple-400 to-purple-500 rounded-xl">
<i class="fas fa-shopping-cart text-white text-2xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Orders</p>
<p id="ordersStat" class="text-3xl font-bold text-gray-900">456</p>
<span class="text-red-600 text-sm font-medium">-3.1%</span>
</div>
</div>
</div>
<div class="bg-white p-6 rounded-xl shadow-lg border border-gray-100 hover:shadow-xl transition-shadow">
<div class="flex items-center">
<div class="p-3 bg-gradient-to-r from-indigo-400 to-indigo-500 rounded-xl">
<i class="fas fa-chart-line text-white text-2xl"></i>
</div>
<div class="ml-4">
<p class="text-sm font-medium text-gray-600">Growth</p>
<p id="growthStat" class="text-3xl font-bold text-gray-900">15.7%</p>
<span class="text-green-600 text-sm font-medium">+15.7%</span>
</div>
</div>
</div>
</div>
<!-- Charts Row -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
<!-- Revenue Line Chart -->
<div class="bg-white p-6 rounded-xl shadow-lg border border-gray-100">
<div class="flex items-center justify-between mb-6">
<h3 class="text-xl font-semibold text-gray-900">Revenue Overview</h3>
<button id="updateRevenueBtn" class="px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition-colors">
Update Data
</button>
</div>
<div class="chart-container">
<canvas id="revenueChart"></canvas>
</div>
</div>
<!-- Sales Bar Chart -->
<div class="bg-white p-6 rounded-xl shadow-lg border border-gray-100">
<div class="flex items-center justify-between mb-6">
<h3 class="text-xl font-semibold text-gray-900">Sales by Category</h3>
<button id="updateSalesBtn" class="px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition-colors">
Update Data
</button>
</div>
<div class="chart-container">
<canvas id="salesChart"></canvas>
</div>
</div>
</div>
<!-- Pie Chart & Recent Orders Row -->
<div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
<!-- User Demographics Pie Chart -->
<div class="bg-white p-6 rounded-xl shadow-lg border border-gray-100">
<h3 class="text-xl font-semibold text-gray-900 mb-6">User Demographics</h3>
<div class="chart-container mx-auto">
<canvas id="pieChart"></canvas>
</div>
</div>
<!-- Recent Orders Table -->
<div class="bg-white p-6 rounded-xl shadow-lg border border-gray-100 overflow-hidden">
<h3 class="text-xl font-semibold text-gray-900 mb-6">Recent Orders</h3>
<div class="overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left font-medium text-gray-900">Order ID</th>
<th class="px-4 py-3 text-left font-medium text-gray-900">Customer</th>
<th class="px-4 py-3 text-left font-medium text-gray-900">Amount</th>
<th class="px-4 py-3 text-left font-medium text-gray-900">Status</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
<tr class="hover:bg-gray-50 transition-colors">
<td class="px-4 py-4 font-mono">#12345</td>
<td class="px-4 py-4">John Doe</td>
<td class="px-4 py-4 text-green-600 font-semibold">$199.99</td>
<td class="px-4 py-4">
<span class="bg-green-100 text-green-800 px-3 py-1 rounded-full text-xs font-medium">Shipped</span>
</td>
</tr>
<tr class="hover:bg-gray-50 transition-colors">
<td class="px-4 py-4 font-mono">#12346</td>
<td class="px-4 py-4">Jane Smith</td>
<td class="px-4 py-4 text-green-600 font-semibold">$89.50</td>
<td class="px-4 py-4">
<span class="bg-yellow-100 text-yellow-800 px-3 py-1 rounded-full text-xs font-medium">Pending</span>
</td>
</tr>
<tr class="hover:bg-gray-50 transition-colors">
<td class="px-4 py-4 font-mono">#12347</td>
<td class="px-4 py-4">Bob Johnson</td>
<td class="px-4 py-4 text-green-600 font-semibold">$299.00</td>
<td class="px-4 py-4">
<span class="bg-red-100 text-red-800 px-3 py-1 rounded-full text-xs font-medium">Cancelled</span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
</div>
<script>
// Sidebar Toggle
const sidebar = document.getElementById('sidebar');
const toggleBtn = document.getElementById('toggleSidebarBtn');
const overlay = document.getElementById('sidebarOverlay');
toggleBtn.addEventListener('click', () => {
sidebar.classList.toggle('-translate-x-full');
overlay.classList.toggle('hidden');
});
overlay.addEventListener('click', () => {
sidebar.classList.add('-translate-x-full');
overlay.classList.add('hidden');
});
// Mock dynamic data
const mockRevenueData = [12000, 19000, 15000, 22000, 28000, 32000, 35000];
const mockSalesData = [400, 300, 500, 450, 600, 550, 700];
const mockPieData = [55, 30, 15];
// Stats data for dynamic updates
const stats = {
revenue: 24392,
users: 1234,
orders: 456,
growth: 15.7
};
// Initialize Charts
let revenueChart, salesChart, pieChart;
function initCharts() {
// Revenue Line Chart
const revenueCtx = document.getElementById('revenueChart').getContext('2d');
revenueChart = new Chart(revenueCtx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
datasets: [{
label: 'Revenue ($)',
data: mockRevenueData,
borderColor: 'rgb(99 102 241)',
backgroundColor: 'rgba(99 102 241, 0.1)',
tension: 0.4,
fill: true
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { position: 'top' } },
scales: {
y: { beginAtZero: true }
}
}
});
// Sales Bar Chart
const salesCtx = document.getElementById('salesChart').getContext('2d');
salesChart = new Chart(salesCtx, {
type: 'bar',
data: {
labels: ['Electronics', 'Clothing', 'Books', 'Home', 'Sports'],
datasets: [{
label: 'Sales',
data: mockSalesData.slice(0, 5),
backgroundColor: [
'rgba(99 102 241, 0.8)',
'rgba(16 185 129, 0.8)',
'rgba(245 158 11, 0.8)',
'rgba(239 68 68, 0.8)',
'rgba(59 130 246, 0.8)'
]
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { position: 'top' } },
scales: { y: { beginAtZero: true } }
}
});
// Pie Chart
const pieCtx = document.getElementById('pieChart').getContext('2d');
pieChart = new Chart(pieCtx, {
type: 'doughnut',
data: {
labels: ['Men', 'Women', 'Other'],
datasets: [{
data: mockPieData,
backgroundColor: ['rgba(99 102 241, 0.8)', 'rgba(16 185 129, 0.8)', 'rgba(245 158 11, 0.8)']
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { position: 'bottom' } }
}
});
}
// Dynamic Update Functions
function updateStats() {
stats.revenue += Math.floor(Math.random() * 1000) - 500;
stats.users += Math.floor(Math.random() * 50) - 25;
stats.orders += Math.floor(Math.random() * 20) - 10;
stats.growth += (Math.random() * 2) - 1;
document.getElementById('revenueStat').textContent = `$${stats.revenue.toLocaleString()}`;
document.getElementById('usersStat').textContent = stats.users.toLocaleString();
document.getElementById('ordersStat').textContent = stats.orders.toLocaleString();
document.getElementById('growthStat').textContent = `${stats.growth.toFixed(1)}%`;
}
function updateRevenueChart() {
revenueChart.data.datasets[0].data = mockRevenueData.map(d => d + (Math.random() * 2000 - 1000));
revenueChart.update('active');
}
function updateSalesChart() {
salesChart.data.datasets[0].data = mockSalesData.map(d => d + (Math.random() * 100 - 50));
salesChart.update('active');
}
// Event Listeners
document.getElementById('updateRevenueBtn').addEventListener('click', updateRevenueChart);
document.getElementById('updateSalesBtn').addEventListener('click', updateSalesChart);
// Auto-update every 10 seconds for demo
setInterval(updateStats, 10000);
// Initialize
initCharts();
updateStats(); // Initial randomization
</script>
</body>
</html>
This is a fully responsive admin dashboard built with Tailwind CSS and Chart.js for dynamic charts.
Key Features:
- Responsive Design: Works on mobile, tablet, and desktop. Sidebar slides in/out on mobile.
- Dynamic Charts:
- Line chart (Revenue) – Updates on button click with randomized data.
- Bar chart (Sales) – Similarly dynamic.
- Doughnut chart (Pie for demographics).
- Stats cards auto-update every 10s.
- Interactive Elements: Sidebar toggle, notifications, search, hover effects.
- Modern UI: Gradients, shadows, transitions, Font Awesome icons.
- Self-Contained: Copy-paste into an HTML file and open in browser – no setup needed.
Charts animate on updates, and data is mocked for dynamism. Customize data sources easily! 🚀