JSFiddle - React, Tailwind, and code Playground
by velo_ninja
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Responsive Sidebar with Floating Tooltips</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet" />
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--sidebar-width: 260px;
--sidebar-bg: linear-gradient(135deg, #007bff, #1e3a8a);
--sidebar-text: #fff;
--hover-bg: rgba(255, 255, 255, 0.15);
--tooltip-bg: #222;
--tooltip-color: #fff;
--transition-time: 0.3s;
--submenu-indent: 20px;
--body-bg: #f4f4f4;
}
body.light {
--sidebar-bg: #f0f0f0;
--sidebar-text: #333;
--hover-bg: rgba(0, 0, 0, 0.1);
--tooltip-bg: #eee;
--tooltip-color: #000;
--body-bg: #fff;
}
body {
font-family: 'Roboto', sans-serif;
background-color: var(--body-bg);
display: flex;
height: 100vh;
}
.sidebar {
position: fixed;
top: 0;
left: 0;
width: var(--sidebar-width);
height: 100vh;
background: var(--sidebar-bg);
color: var(--sidebar-text);
padding: 20px;
overflow-y: auto;
overflow-x: visible;
display: flex;
flex-direction: column;
z-index: 10;
}
.sidebar .title {
text-align: center;
font-size: 1.6rem;
font-weight: bold;
margin-bottom: 15px;
}
.nav-menu ul {
list-style: none;
}
.nav-menu li {
margin: 0;
position: relative;
overflow: visible;
}
.nav-menu a {
text-decoration: none;
color: var(--sidebar-text);
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px 15px;
...