Template com mudanças de temas para o Bootstrap 5.3
Sat May 20 2023 21:00:50 GMT+0000 (Coordinated Universal Time)
Saved by @lucashayashi #html #bootstrap
<!DOCTYPE html> <html lang="pt-BR" data-bs-theme="light"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <header> <nav class="navbar navbar-expand-lg bg-body-tertiary"> <div class="container"> <a class="navbar-brand" href="#">SeuSite</a> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarSupportedContent"> <ul class="navbar-nav me-auto mb-2 mb-lg-0"> <li class="nav-item"> <a class="nav-link active" aria-current="page" href="#">Home</a> </li> </ul> </div> <div class="d-flex"> <ul class="navbar-nav"> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle current-theme" data-bs-toggle="dropdown" href="#" role="button" aria-expanded="false"> Tema </a> <ul class="dropdown-menu themes-list"> <li> <a class="dropdown-item" href="#" data-theme="light"> <i class="bi bi-brightness-high"></i> Claro </a> </li> <li> <a class="dropdown-item" href="#" data-theme="dark"> <i class="bi bi-moon-stars-fill"></i> Escuro </a> </li> <li> <a class="dropdown-item" href="#" data-theme="auto"> <i class="bi bi-circle-half"></i> Auto </a> </li> </ul> </li> </ul> </div> </div> </nav> </header> <main> <div class="container"> <h1>Hello World!</h1> <!-- Seu conteúdo aqui --> </div> </main> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script> <script> $(document).ready(function() { function removerActiveClassTheme() { $('.themes-list li a').removeClass('active'); } $('.themes-list li').on('click', function() { let linkElement = $(this).find('a'); let theme = linkElement.data('theme'); $('html').attr('data-bs-theme', theme); removerActiveClassTheme(); linkElement.addClass('active'); }) }); </script> </body> </html>
Comments