Admin Dashboard UI with HTML, CSS & JavaScript
40 DAYS 40 PROJECT CHALLENGE
Day #01
Project Overview
A modern Admin Dashboard UI built using HTML, CSS, and JavaScript, designed with a clean and responsive layout.
The dashboard allows administrators to log in, manage users, and view user statistics through an interactive interface. It demonstrates frontend concepts such as form validation, dynamic table updates, sidebar navigation, search functionality, and LocalStorage-based data management, making it a great project for beginners learning real-world dashboard design.
Key Features
- Secure Admin Login system with basic authentication.
- Responsive dashboard layout with sidebar navigation.
- Add, edit, and delete users dynamically.
- User statistics cards showing total and active users.
- Real-time search functionality for filtering users.
- Data stored in LocalStorage for frontend demonstration.
- Mobile responsive design with collapsible sidebar.
- Clean UI cards and tables for better data visualization.
- Logout functionality to exit the dashboard securely.
- Interactive UI elements using JavaScript DOM manipulation.
HTML Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Admin Dashboard</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- LOGIN PAGE -->
<div class="login-page" id="loginPage">
<div class="login-box">
<h2>Admin Login</h2>
<input type="text" id="username" placeholder="Username">
<input type="password" id="password" placeholder="Password">
<button onclick="login()">Login</button>
<p class="error" id="loginError"></p>
</div>
</div>
<!-- DASHBOARD -->
<div class="dashboard" id="dashboard">
<div class="sidebar" id="sidebar">
<span class="close-btn" onclick="toggleSidebar()">✕</span>
<h2>Admin Panel</h2>
<ul>
<li>Dashboard</li>
<li>Users</li>
<li onclick="logout()">Logout</li>
</ul>
</div>
<div class="main">
<div class="topbar">
<button onclick="toggleSidebar()">☰</button>
<h3>Admin Dashboard</h3>
</div>
<!-- Cards -->
<div class="cards">
<div class="card">
<h4>Total Users</h4>
<p id="totalUsers">0</p>
</div>
<div class="card">
<h4>Active Users</h4>
<p id="activeUsers">0</p>
</div>
</div>
<!-- Add/Edit User -->
<div class="form-box">
<h3>Add / Edit User</h3>
<input type="hidden" id="editId">
<input type="text" id="name" placeholder="Name">
<input type="email" id="email" placeholder="Email">
<button onclick="saveUser()">Save</button>
<p class="error" id="formError"></p>
</div>
<!-- Search -->
<input type="text" id="search" placeholder="Search..." onkeyup="searchUser()">
<!-- Table -->
<div class="table-box">
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Action</th>
</tr>
</thead>
<tbody id="userTable"></tbody>
</table>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html> CSS Code
*{
margin:0;
padding:0;
box-sizing:border-box;
font-family:Segoe UI, sans-serif;
}
body{
background:#042354;
}
/* LOGIN */
.login-page{
height:100vh;
display:flex;
justify-content:center;
align-items:center;
}
.login-box{
background:#fff;
padding:30px;
width:320px;
border-radius:8px;
box-shadow:0 5px 20px rgba(0,0,0,0.1);
}
.login-box h2{
text-align:center;
margin-bottom:20px;
}
.login-box input{
width:100%;
padding:10px;
margin:8px 0;
}
.login-box button{
width:100%;
padding:10px;
background:#2c3e50;
color:#fff;
border:none;
cursor:pointer;
}
.error{
color:red;
font-size:14px;
margin-top:5px;
}
/* DASHBOARD */
.dashboard{
display:none;
}
.sidebar{
width:230px;
height:100vh;
background:#2c3e50;
color:#fff;
position:fixed;
padding:20px;
transition:0.3s;
left:0;
}
.sidebar h2{
margin-bottom:20px;
}
.sidebar ul li{
list-style:none;
margin:15px 0;
cursor:pointer;
}
.main{
margin-left:230px;
padding:20px;
transition:0.3s;
}
.topbar{
display:flex;
justify-content:space-between;
align-items:center;
margin-bottom:20px;
}
.topbar button{
padding:5px 10px;
cursor:pointer;
}
/* CARDS */
.cards{
display:flex;
gap:15px;
flex-wrap:wrap;
margin-bottom:20px;
}
.card{
flex:1 1 200px;
background:#fff;
padding:20px;
border-radius:8px;
box-shadow:0 2px 10px rgba(0,0,0,0.05);
}
/* FORM */
.form-box{
background:#fff;
padding:20px;
border-radius:8px;
margin-bottom:20px;
}
.form-box input{
padding:8px;
margin-right:10px;
margin-top:10px;
}
.form-box button{
padding:8px 12px;
}
/* TABLE */
.table-box{
background:#fff;
padding:20px;
border-radius:8px;
overflow-x:auto;
width:100%;
}
table{
width:100%;
border-collapse:collapse;
}
th, td{
padding:10px;
border:1px solid #ddd;
}
button.edit{
background:orange;
border:none;
padding:5px 10px;
color:#fff;
}
button.delete{
background:red;
border:none;
padding:5px 10px;
color:#fff;
}
/* SEARCH */
#search{
padding:8px;
margin-bottom:10px;
width:250px;
}
.close-btn{
position:absolute;
top:15px;
right:20px;
font-size:22px;
cursor:pointer;
display:none;
}
/* MOBILE RESPONSIVE */
@media (max-width:768px){
/* Topbar */
.topbar h3{
font-size:18px;
}
/* Cards */
.cards{
flex-direction:column;
}
.card{
width:100%;
}
/* Form */
.form-box input{
width:100%;
margin:8px 0;
}
.form-box button{
width:100%;
margin-top:10px;
}
/* Search */
#search{
width:100%;
}
/* Table */
table{
font-size:14px;
}
th,td{
padding:8px;
}
/* Sidebar */
.sidebar{
left:-230px;
z-index:1000;
}
.sidebar.active{
left:0;
}
.main{
margin-left:0;
}
/* Topbar button */
.topbar button{
font-size:20px;
}
.close-btn{
display:block;
color:white;
}
} Javascript Code
let users = JSON.parse(localStorage.getItem("users")) || [];
let userId = users.length ? users[users.length-1]?.id + 1 : 1;
/* CHECK LOGIN STATUS ON LOAD */
window.onload = function() {
if(sessionStorage.getItem("isLoggedIn") === "true"){
document.getElementById("loginPage").style.display="none";
document.getElementById("dashboard").style.display="block";
renderUsers();
}
}
/* LOGIN */
function login(){
const user = document.getElementById("username").value;
const pass = document.getElementById("password").value;
if(user === "admin" && pass === "1234"){
sessionStorage.setItem("isLoggedIn","true");
document.getElementById("loginPage").style.display="none";
document.getElementById("dashboard").style.display="block";
renderUsers();
}else{
document.getElementById("loginError").textContent="Invalid Credentials!";
}
}
/* LOGOUT */
function logout(){
sessionStorage.removeItem("isLoggedIn");
document.getElementById("dashboard").style.display="none";
document.getElementById("loginPage").style.display="flex";
}
/* SIDEBAR */
function toggleSidebar(){
document.getElementById("sidebar").classList.toggle("active");
}
/* SAVE USER */
function saveUser(){
const name=document.getElementById("name").value.trim();
const email=document.getElementById("email").value.trim();
const editId=document.getElementById("editId").value;
if(!name || !email){
document.getElementById("formError").textContent="All fields required!";
return;
}
if(editId){
users=users.map(u=>u.id==editId?{...u,name,email}:u);
document.getElementById("editId").value="";
}else{
users.push({id:userId++,name,email});
}
localStorage.setItem("users",JSON.stringify(users));
document.getElementById("name").value="";
document.getElementById("email").value="";
document.getElementById("formError").textContent="";
renderUsers();
}
/* RENDER USERS */
function renderUsers(){
const table=document.getElementById("userTable");
table.innerHTML="";
users.forEach(user=>{
table.innerHTML+=`
<tr>
<td>${user.id}</td>
<td>${user.name}</td>
<td>${user.email}</td>
<td>
<button class="edit" onclick="editUser(${user.id})">Edit</button>
<button class="delete" onclick="deleteUser(${user.id})">Delete</button>
</td>
</tr>
`;
});
document.getElementById("totalUsers").textContent=users.length;
document.getElementById("activeUsers").textContent=users.length;
}
/* EDIT */
function editUser(id){
const user=users.find(u=>u.id==id);
document.getElementById("name").value=user.name;
document.getElementById("email").value=user.email;
document.getElementById("editId").value=id;
}
/* DELETE */
function deleteUser(id){
users=users.filter(u=>u.id!=id);
localStorage.setItem("users",JSON.stringify(users));
renderUsers();
}
/* SEARCH */
function searchUser(){
const value=document.getElementById("search").value.toLowerCase();
const rows=document.querySelectorAll("#userTable tr");
rows.forEach(row=>{
const name=row.cells[1].innerText.toLowerCase();
row.style.display=name.includes(value)?"":"none";
});
} Related Projects
Day 3 : E-commerce Product Page
Generates an OTP via alert and verifies it through a popup-based input UI.
Concepts: DOM manipulation, modal UI, random OTP generation, input handling.
Day 4 : Invoice Generator
Creates invoices dynamically with item details and real-time total calculation.
Concepts: DOM manipulation, form handling, calculations, data rendering.
Day 5 : Chat UI (Frontend Only)
A simple chat interface with message sending and display functionality.
Concepts: DOM manipulation, event handling, dynamic UI updates.