Navbar Dark Sidebar

menu com sidebar

NAVBAR

Código

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Navbar + Sidebar Example</title>
  <!-- Bootstrap CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
  
  <style>
    /* Estilos para harmonizar a navbar e sidebar */
    body {
      padding-top: 56px;
    }

    .navbar {
      background-color: #141414;
      position: fixed;
      width: 100%;
      z-index: 1040;
    }

    .navbar-brand {
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
    }

    .sidebar {
      height: 100vh;
      width: 250px;
      position: fixed;
      top: 0; /* Ajustar para estar no topo */
      left: -250px;
      background-color: #141414;
      transition: all 0.3s;
      padding-top: 56px; /* Abaixo da navbar */
      z-index: 1030;
    }

    .sidebar.active {
      left: 0;
    }

    .sidebar ul {
      padding: 0;
      margin: 0;
      list-style: none;
    }

    .sidebar ul li {
      padding: 15px;
    }

    .sidebar ul li a {
      color: #fff;
      text-decoration: none;
      display: block;
    }

    .sidebar ul li a:hover {
      background-color: #E50914;
    }

    .toggle-btn {
      margin-right: 15px;
    }

    /* Ajuste do conteúdo principal ao abrir o sidebar */
    .content {
      margin-left: 0;
      transition: all 0.3s;
    }

    .content.active {
      margin-left: 250px;
    }

    /* Cores */
    .navbar-dark .navbar-nav .nav-link {
      color: #fff;
    }

    .btn-login {
      background-color: #E50914;
      color: white;
    }

    .dropdown-menu {
      background-color: #141414;
    }

    .navbar-toggler {
      border-color: rgba(255, 255, 255, 0.1);
    }
  </style>
</head>
<body>

<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-dark">
  <div class="container-fluid">
    <!-- Sidebar Toggle Button -->
    <button class="navbar-toggler toggle-btn" type="button">
      <span class="navbar-toggler-icon"></span>
    </button>

    <!-- Logotipo (Centralizado) -->
    <a class="navbar-brand" href="#">
      <img src="https://via.placeholder.com/100x40" alt="Logo" height="40">
    </a>

    <!-- Navbar Menu -->
    <div class="collapse navbar-collapse justify-content-between" id="navbarNav">
      <ul class="navbar-nav me-auto">
        <li class="nav-item">
          <a class="nav-link active" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Sobre</a>
        </li>
        <!-- Submenu -->
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Serviços
          </a>
          <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
            <li><a class="dropdown-item" href="#">Desenvolvimento Web</a></li>
            <li><a class="dropdown-item" href="#">Design Gráfico</a></li>
            <li><a class="dropdown-item" href="#">SEO</a></li>
          </ul>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Contato</a>
        </li>
      </ul>

      <!-- Botão de Login -->
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="btn btn-login" href="#">
            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-arrow-in-right" viewBox="0 0 16 16">
              <path fill-rule="evenodd" d="M6 3a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1H6.5v10H11a.5.5 0 0 1 0 1H6.5A.5.5 0 0 1 6 13V3zm3.146 8.354a.5.5 0 0 1 0-.708L11.293 8 9.146 5.854a.5.5 0 1 1 .708-.708l2.5 2.5a.5.5 0 0 1 0 .708l-2.5 2.5a.5.5 0 0 1-.708 0z"/>
            </svg>
            Login
          </a>
        </li>
      </ul>
    </div>
  </div>
</nav>

<!-- Sidebar -->
<div class="sidebar" id="sidebar">
  <ul>
    <li><a href="#">Dashboard</a></li>
    <li><a href="#">Relatórios</a></li>
    <li><a href="#">Configurações</a></li>
    <li><a href="#">Ajuda</a></li>
  </ul>
</div>

<!-- Conteúdo Principal -->
<div class="content" id="content">
  <div class="container mt-5">
    <h1>Conteúdo Principal</h1>
    <p>Este é um exemplo de layout com uma barra de navegação superior e uma barra lateral que pode ser aberta e fechada.</p>
  </div>
</div>

<!-- Bootstrap JS and Popper.js -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>

<script>
  // Script para alternar o sidebar
  document.querySelector('.toggle-btn').addEventListener('click', function() {
    document.getElementById('sidebar').classList.toggle('active');
    document.getElementById('content').classList.toggle('active');
  });
</script>

</body>
</html>