<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Tailwind Admin Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Tailwind CSS CDN -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Chart.js CDN -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body class="bg-gray-100 text-gray-900">
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<aside
id="sidebar"
class="fixed inset-y-0 left-0 z-30 w-64 transform bg-white border-r border-gray-200 shadow-lg transition-transform duration-200 ease-in-out -translate-x-full md:translate-x-0 md:static md:inset-auto"
>
<div class="flex items-center justify-between px-4 py-4 border-b border-gray-200">
<span class="text-lg font-semibold tracking-tight">My Admin</span>
<button
id="sidebarClose"
class="p-1 text-gray-500 rounded-md hover:bg-gray-100 md:hidden"
>
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
<nav class="px-4 py-4 space-y-2">
<a href="#"
class="flex items-center px-3 py-2 text-sm font-medium rounded-md bg-gray-100 text-gray-900">
<span class="mr-3">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"/>
</svg>
</span>
Dashboard
</a>
<a href="#"
class="flex items-center px-3 py-2 text-sm font-medium text-gray-600 rounded-md hover:bg-gray-50 hover:text-gray-900">
<span class="mr-3">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 17v-6a2 2 0 012-2h8M9 5l7 7-7 7"/>
</svg>
</span>
Reports
</a>
<a href="#"
class="flex items-center px-3 py-2 text-sm font-medium text-gray-600 rounded-md hover:bg-gray-50 hover:text-gray-900">
<span class="mr-3">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M3 7h18M3 12h18M3 17h18"/>
</svg>
</span>
Orders
</a>
<a href="#"
class="flex items-center px-3 py-2 text-sm font-medium text-gray-600 rounded-md hover:bg-gray-50 hover:text-gray-900">
<span class="mr-3">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M5.121 17.804A13.937 13.937 0 0112 15c2.5 0 4.847.655 6.879 1.804M15 11a3 3 0 11-6 0 3 3 0 016 0z"/>
</svg>
</span>
Users
</a>
<a href="#"
class="flex items-center px-3 py-2 text-sm font-medium text-gray-600 rounded-md hover:bg-gray-50 hover:text-gray-900">
<span class="mr-3">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 8c-1.657 0-3 .843-3 1.882V11h6v-1.118C15 8.843 13.657 8 12 8zM5 11h14v7H5z"/>
</svg>
</span>
Settings
</a>
</nav>
</aside>
<!-- Mobile sidebar backdrop -->
<div
id="sidebarBackdrop"
class="fixed inset-0 z-20 bg-black bg-opacity-40 hidden md:hidden"
></div>
<!-- Main content area -->
<div class="flex flex-col flex-1 min-w-0 overflow-hidden">
<!-- Top navbar -->
<header class="flex items-center justify-between px-4 py-3 bg-white border-b border-gray-200">
<div class="flex items-center space-x-2">
<button
id="sidebarOpen"
class="p-2 text-gray-600 rounded-md hover:bg-gray-100 md:hidden"
>
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"/>
</svg>
</button>
<h1 class="text-lg font-semibold md:text-xl">Dashboard</h1>
</div>
<div class="flex items-center space-x-4">
<div class="hidden sm:block">
<div class="relative">
<span class="absolute inset-y-0 left-0 flex items-center pl-3 text-gray-400">
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M8 16l-4 4m0 0l4-4m-4 4V4a2 2 0 012-2h10a2 2 0 012 2v4"/>
</svg>
</span>
<input
type="text"
placeholder="Search..."
class="w-48 py-1.5 pl-8 pr-3 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
/>
</div>
</div>
<button class="relative p-2 text-gray-500 rounded-full hover:bg-gray-100">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M15 17h5l-1.405-1.405M19 13a7 7 0 10-14 0 7 7 0 0014 0z"/>
</svg>
<span
class="absolute top-1 right-1 inline-flex items-center justify-center w-3 h-3 text-[10px] font-semibold text-white bg-red-500 rounded-full"
>
3
</span>
</button>
<div class="flex items-center space-x-2">
<span class="hidden text-sm font-medium sm:inline">Admin</span>
<div class="w-8 h-8 overflow-hidden bg-gray-200 rounded-full">
<img
src="https://i.pravatar.cc/100?img=3"
alt="Avatar"
class="object-cover w-full h-full"
/>
</div>
</div>
</div>
</header>
<!-- Main content -->
<main class="flex-1 min-w-0 p-4 overflow-y-auto md:p-6">
<!-- Stats cards -->
<section class="grid grid-cols-1 gap-4 mb-6 sm:grid-cols-2 lg:grid-cols-4">
<div class="p-4 bg-white rounded-lg shadow">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Total Sales</p>
<p id="statSales" class="mt-1 text-2xl font-semibold text-gray-900">$24,500</p>
</div>
<div class="p-2 bg-green-100 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-green-600" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M5 10l4 4L19 4"/>
</svg>
</div>
</div>
<p class="mt-2 text-xs text-green-600">+12% vs last month</p>
</div>
<div class="p-4 bg-white rounded-lg shadow">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">New Users</p>
<p id="statUsers" class="mt-1 text-2xl font-semibold text-gray-900">1,245</p>
</div>
<div class="p-2 bg-blue-100 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-blue-600" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M5.121 17.804A13.937 13.937 0 0112 15c2.5 0 4.847.655 6.879 1.804M15 11a3 3 0 11-6 0 3 3 0 016 0z"/>
</svg>
</div>
</div>
<p class="mt-2 text-xs text-gray-500">Last 30 days</p>
</div>
<div class="p-4 bg-white rounded-lg shadow">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Active Sessions</p>
<p id="statSessions" class="mt-1 text-2xl font-semibold text-gray-900">324</p>
</div>
<div class="p-2 bg-yellow-100 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-yellow-600" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
</div>
<p class="mt-2 text-xs text-yellow-600">+5.3% in the last hour</p>
</div>
<div class="p-4 bg-white rounded-lg shadow">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Conversion Rate</p>
<p id="statConversion" class="mt-1 text-2xl font-semibold text-gray-900">3.8%</p>
</div>
<div class="p-2 bg-purple-100 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5 text-purple-600" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 17v-6a2 2 0 012-2h8M9 5l7 7-7 7"/>
</svg>
</div>
</div>
<p class="mt-2 text-xs text-purple-600">+0.4% today</p>
</div>
</section>
<!-- Charts -->
<section class="grid grid-cols-1 gap-6 lg:grid-cols-3">
<!-- Line chart -->
<div class="col-span-1 bg-white rounded-lg shadow lg:col-span-2">
<div class="flex items-center justify-between px-4 py-3 border-b border-gray-100">
<h2 class="text-sm font-semibold text-gray-700 uppercase">Revenue (Live)</h2>
<span class="text-xs text-gray-400">Updates every 3s</span>
</div>
<div class="p-4">
<canvas id="lineChart" class="w-full h-64"></canvas>
</div>
</div>
<!-- Bar chart -->
<div class="bg-white rounded-lg shadow">
<div class="flex items-center justify-between px-4 py-3 border-b border-gray-100">
<h2 class="text-sm font-semibold text-gray-700 uppercase">Signups by Channel</h2>
<span class="text-xs text-gray-400">Live sample</span>
</div>
<div class="p-4">
<canvas id="barChart" class="w-full h-64"></canvas>
</div>
</div>
</section>
</main>
</div>
</div>
<!-- Scripts -->
<script>
// Sidebar toggle logic (mobile)
document.addEventListener("DOMContentLoaded", () => {
const sidebar = document.getElementById("sidebar");
const sidebarBackdrop = document.getElementById("sidebarBackdrop");
const sidebarOpen = document.getElementById("sidebarOpen");
const sidebarClose = document.getElementById("sidebarClose");
function openSidebar() {
sidebar.classList.remove("-translate-x-full");
sidebarBackdrop.classList.remove("hidden");
}
function closeSidebar() {
sidebar.classList.add("-translate-x-full");
sidebarBackdrop.classList.add("hidden");
}
sidebarOpen.addEventListener("click", openSidebar);
sidebarClose.addEventListener("click", closeSidebar);
sidebarBackdrop.addEventListener("click", closeSidebar);
});
</script>
<script>
// Dynamic charts with Chart.js
document.addEventListener("DOMContentLoaded", () => {
const lineCtx = document.getElementById("lineChart").getContext("2d");
const barCtx = document.getElementById("barChart").getContext("2d");
// Initial data
const initialLabels = ["09:00", "09:05", "09:10", "09:15", "09:20", "09:25"];
const initialRevenue = [1200, 1500, 1800, 1600, 1900, 2100];
const lineChart = new Chart(lineCtx, {
type: "line",
data: {
labels: initialLabels,
datasets: [
{
label: "Revenue ($)",
data: initialRevenue,
borderColor: "#3b82f6",
backgroundColor: "rgba(59, 130, 246, 0.15)",
tension: 0.3,
fill: true,
pointRadius: 3,
pointBackgroundColor: "#3b82f6",
},
],
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false },
},
scales: {
x: {
grid: { display: false },
ticks: { color: "#6b7280" },
},
y: {
beginAtZero: false,
grid: { color: "#e5e7eb" },
ticks: { color: "#6b7280" },
},
},
},
});
const barChart = new Chart(barCtx, {
type: "bar",
data: {
labels: ["Organic", "Ads", "Referral", "Social", "Email"],
datasets: [
{
label: "Signups",
data: [120, 90, 60, 80, 45],
backgroundColor: [
"#6366f1",
"#10b981",
"#f59e0b",
"#3b82f6",
"#ec4899",
],
borderRadius: 4,
},
],
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false },
},
scales: {
x: {
grid: { display: false },
ticks: { color: "#6b7280" },
},
y: {
beginAtZero: true,
grid: { color: "#e5e7eb" },
ticks: { color: "#6b7280" },
},
},
},
});
// Helpers for live updates
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function addDataToLineChart(chart) {
const now = new Date();
const label =
now.getHours().toString().padStart(2, "0") +
":" +
now.getMinutes().toString().padStart(2, "0");
// New revenue value based on last value +/- random delta
const lastValue =
chart.data.datasets[0].data[chart.data.datasets[0].data.length - 1] || 1500;
const delta = randomInt(-200, 250);
const nextValue = Math.max(500, lastValue + delta);
chart.data.labels.push(label);
chart.data.datasets[0].data.push(nextValue);
// Keep only latest 10 points
if (chart.data.labels.length > 10) {
chart.data.labels.shift();
chart.data.datasets[0].data.shift();
}
chart.update("active");
// Update metric card to reflect last value
const statSales = document.getElementById("statSales");
if (statSales) {
statSales.textContent = "$" + nextValue.toLocaleString();
}
}
function randomizeBarChart(chart) {
chart.data.datasets[0].data = chart.data.datasets[0].data.map(() =>
randomInt(30, 180)
);
chart.update("active");
// Also update some stat cards to look "live"
const statUsers = document.getElementById("statUsers");
const statSessions = document.getElementById("statSessions");
const statConversion = document.getElementById("statConversion");
if (statUsers) statUsers.textContent = randomInt(900, 1800).toLocaleString();
if (statSessions) statSessions.textContent = randomInt(200, 500).toLocaleString();
if (statConversion) statConversion.textContent = (Math.random() * 5 + 1).toFixed(1) + "%";
}
// Live update intervals
setInterval(() => {
addDataToLineChart(lineChart);
randomizeBarChart(barChart);
}, 3000);
});
</script>
</body>
</html>