JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Boxicons -->
<link href='https://unpkg.com/boxicons@2.0.9/css/boxicons.min.css' rel='stylesheet'>
<!-- My CSS -->
<link rel="stylesheet" href="style.css">
<title>Dashboard</title>
</head>
<body>
<!-- SIDEBAR -->
<section id="sidebar">
<a href="#" class="brand">
<i class='bx bxs-home'></i>
<span class="text">Dashboard</span>
</a>
<ul class="side-menu top">
<li class="active">
<a href="#">
<i class='bx bxs-dashboard'></i>
<span class="text">Dashboard</span>
</a>
</li>
<li>
<a href="#">
<i class='bx bxs-shopping-bag-alt'></i>
<span class="text">My Store</span>
</a>
</li>
<li>
<a href="#">
<i class='bx bxs-doughnut-chart'></i>
<span class="text">Analytics</span>
</a>
</li>
<li>
<a href="#">
<i class='bx bxs-message-dots'></i>
<span class="text">Message</span>
</a>
<!-- Submenu -->
<!-- <ul class="submenu">
<li><a href="#">Team Member 1</a></li>
<li><a href="#">Team Member 2</a></li>
<li><a href="#">Team Member 3</a></li>
</ul> -->
</li>
<li>
<a href="#">
<i class='bx bxs-group'></i>
<span class="text">Team</span>
</a>
</li>
</ul>
</section>
<!-- SIDEBAR -->
<!-- CONTENT -->
<section id="content">
<!-- NAVBAR -->
<nav>
<i class='bx bx-menu'></i>
<form></form>
<input type="checkbox" id="switch-mode" hidden>
<label for="switch-mode" class="switch-mode"></label>
<a href="#" class="profile">
<img src="https://upload.wikimedia.org/wikipedia/commons/9/99/Sample_User_Icon.png">
</a>
</nav>
<!-- NAVBAR -->
<!-- MAIN -->
<main>
<ul class="box-info">
<li>
<i class='bx bxs-calendar-check'></i>
<span class="text">
<h3>1337</h3>
<p>New Order</p>
</span>
</li>
<li>
<i class='bx...
CSS
@import url("https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
a {
text-decoration: none;
}
li {
list-style: none;
}
:root {
--poppins: "Poppins", sans-serif;
--lato: "Lato", sans-serif;
--light: #f9f9f9;
--blue: #3c91e6;
--light-blue: #cfe8ff;
--grey: #eee;
--dark-grey: #aaaaaa;
--dark: #342e37;
--red: #db504a;
--yellow: #ffce26;
--light-yellow: #fff2c6;
--orange: #fd7238;
--light-orange: #ffe0d3;
}
html {
overflow-x: hidden;
}
body.dark {
--light: #0c0c1e;
--grey: #060714;
--dark: #fbfbfb;
}
body {
background: var(--grey);
overflow-x: hidden;
}
/* SIDEBAR */
#sidebar {
position: fixed;
top: 0;
left: 0;
width: 280px;
height: 100%;
background: var(--light);
z-index: 2000;
font-family: var(--lato);
transition: 0.3s ease;
overflow-x: hidden;
scrollbar-width: none;
}
#sidebar::state(webkit-scrollbar) {
display: none;
}
#sidebar.hide {
width: 60px;
}
#sidebar .brand {
font-size: 24px;
font-weight: 700;
height: 56px;
display: flex;
align-items: center;
color: var(--blue);
position: sticky;
top: 0;
left: 0;
background: var(--light);
z-index: 500;
padding-bottom: 20px;
box-sizing: content-box;
}
#sidebar .brand .bx {
min-width: 60px;
display: flex;
justify-content: center;
}
#sidebar .side-menu {
width: 100%;
}
#sidebar .side-menu li {
height: 48px;
background: transparent;
margin-left: 6px;
border-radius: 48px 0 0 48px;
padding: 4px;
}
#sidebar .side-menu li.active {
/* */
background: var(--grey);
position: relative;
}
#sidebar .side-menu li.active::before {
content: "";
position: absolute;
width: 40px;
height: 40px;
border-radius: 50%;
top: -40px;
right: 0;
box-shadow: 20px 20px 0 var(--grey);
z-index: -1;
}
#sidebar .side-menu li.active::after {
content: "";
position: absolute;
width: 40px;
...
JavaScript
const allSideMenu = document.querySelectorAll('#sidebar .side-menu.top li a');
const menuBar = document.querySelector('#content nav .bx.bx-menu');
const sidebar = document.getElementById('sidebar');
const switchMode = document.getElementById('switch-mode');
// ACTIVE MENU
allSideMenu.forEach(item => {
const li = item.parentElement;
item.addEventListener('click', () => {
allSideMenu.forEach(i => {
i.parentElement.classList.remove('active');
})
li.classList.add('active');
})
});
// TOGGLE SIDEBAR
menuBar.addEventListener('click', () => {
sidebar.classList.toggle('hide');
})
// DARK MODE
switchMode.addEventListener('change', function () {
if (this.checked) {
document.body.classList.add('dark');
} else {
document.body.classList.remove('dark');
}
})