Dynami_Sidebar_Menu 1.0

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;
      position: relative;
      overflow-x: visible;
    }

    .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;
    ...

JavaScript

<script>
      // Example nested menu data with infinite nesting capability
      const sidebarMenuData = [
        { 
          label: "DASHBOARD", 
          icon: "fa-tachometer-alt", 
          path: "/dashboard" 
        },
        { 
          label: "OPTIONS", 
          icon: "fa-sliders-h", 
          path: "/options",
          children: [
            { 
              label: "General", 
              icon: "fa-gear", 
              path: "/options/general" 
            },
            { 
              label: "Advanced", 
              icon: "fa-cogs", 
              path: "/options/advanced",
              children: [
                { label: "Security", icon: "fa-shield-alt", path: "/options/advanced/security" },
                { 
                  label: "Integrations", 
                  icon: "fa-plug", 
                  path: "/options/advanced/integrations",
                  children: [
                    { label: "API", icon: "fa-code", path: "/options/advanced/integrations/api" }
                  ]
                }
              ]
            }
          ]
        },
        { 
          label: "REPORTS", 
          icon: "fa-chart-line", 
          path: "/reports" 
        },
        { 
          label: "LOGS", 
          icon: "fa-file-lines", 
          path: "/logs",
          children: [
            { label: "System", icon: "fa-server", path: "/logs/system" },
            { label: "Application", icon: "fa-code", path: "/logs/application" }
          ]
        },
        { 
          label: "CONFIGS", 
          icon: "fa-cogs", 
          path: "/configs" 
        },
        { 
          label: "CONTACTS", 
          icon: "fa-address-book", 
          path: "/contacts" 
        },
        { 
          label: "DIAGNOSTICS", 
          icon: "fa-flask", 
          path: "/test-routes" 
        },
        { 
          label: "PACKAGES", 
          icon: "fa-box-open", 
          path: "/installations" 
        }
      ];

      // Load...