Responsive Side Navigation Bar With Tooltips in HTML, CSS and JavaScript
A responsive side navigation bar not only helps to improve the navigation of your website but also address the issue of neatly placing links that enhance the experience of users. By using tooltips, it is possible to make the users aware of functions of each link, including when the design is compact.
In this tutorial, I will explain the complete code to create a Responsive Side Bar Navigation with Tooltips in html, css, javascript.
This is great news for those who have been wanting a clean and simple sidebar that is responsive to screens of different sizes.
GitHub Source: Responsive Side Navigation Bar With Tooltips in HTML, CSS and JavaScript
Features
- Easy to Customize: It is very easier to change colors, icons and style according to your website ’s theme.
- Tooltips: Sidebar has tooltip to enhance user experience.
- Icons Used: Includes icons to make the navigation beautiful.
- Compatibility: It works fine on latest browsers and is compatible with all the available resolutions.
- Clean Code: It is well structural to allow the first time programmer to read and tweak without getting lost in the syntax.
Technologies Used
- HTML (Hypertext Markup Language)
- CSS (Cascading Style Sheets)
- JS (JavaScript)
Don’t Miss These
- Simple Responsive Navigation Menu Bar
- Responsive Drop Down Menu Bar with Sub Menu
- Navigation Bar with Dark and Light Mode
- Sticky Navigation Menu Bar
- Elastic Animation Navigation Menu Bar
- Navigation Bar with Indicator
Video Tutorial
Steps to Build Sidebar Menu
- Create Project Folder: Firstly, let’s create a new folder to contain all the files associated with the project.
- Create index.html: Create HTML file for the structure and content of the sidebar.
- Create style.css: Use of css file that will style the navigation bar and the tooltips.
- Create script.js: The interactive part consists of a JavaScript file for toggling between the showing and hiding of the tooltips.
- Copy & paste the code: To get the navigation working on site, use the code following to set sidebar quickly for you.
HTML
Here is the HTML code for your index.html file:
<!DOCTYPE html> <!-- Created by JV Codes |www.jvcodes.com--> <html lang="en" dir="ltr"> <head> <meta charset="UTF-8"> <title> Responsive Sidebar Menu | JV Codes </title> <link rel="stylesheet" href="style.css"> <!-- Boxicons CDN Link --> <link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div class="sidebar"> <div class="logo-details"> <i class='bx bxl-c-plus-plus icon'></i> <div class="logo_name">JV Codes</div> <i class='bx bx-menu' id="btn" ></i> </div> <ul class="nav-list"> <li> <i class='bx bx-search' ></i> <input type="text" placeholder="Search..."> <span class="tooltip">Search</span> </li> <li> <a href="#"> <i class='bx bx-grid-alt'></i> <span class="links_name">Dashboard</span> </a> <span class="tooltip">Dashboard</span> </li> <li> <a href="#"> <i class='bx bx-user' ></i> <span class="links_name">User</span> </a> <span class="tooltip">User</span> </li> <li> <a href="#"> <i class='bx bx-chat' ></i> <span class="links_name">Messages</span> </a> <span class="tooltip">Messages</span> </li> <li> <a href="#"> <i class='bx bx-pie-chart-alt-2' ></i> <span class="links_name">Analytics</span> </a> <span class="tooltip">Analytics</span> </li> <li> <a href="#"> <i class='bx bx-folder' ></i> <span class="links_name">File Manager</span> </a> <span class="tooltip">Files</span> </li> <li> <a href="#"> <i class='bx bx-cart-alt' ></i> <span class="links_name">Order</span> </a> <span class="tooltip">Order</span> </li> <li> <a href="#"> <i class='bx bx-heart' ></i> <span class="links_name">Saved</span> </a> <span class="tooltip">Saved</span> </li> <li> <a href="#"> <i class='bx bx-cog' ></i> <span class="links_name">Setting</span> </a> <span class="tooltip">Setting</span> </li> <li class="profile"> <div class="profile-details"> <img src="profile.jpg" alt="profileImg"> <div class="name_job"> <div class="name">Shokat Javed</div> <div class="job">Apps Developer</div> </div> </div> <i class='bx bx-log-out' id="log_out" ></i> </li> </ul> </div> <section class="home-section"> <div class="text">Dashboard</div> </section> <script src="script.js"></script> </body> </html>
CSS
Here is the complete code for style.css file to style the sidebar menu:
/* Google Font Link */ @import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap'); *{ margin: 0; padding: 0; box-sizing: border-box; font-family: "Poppins" , sans-serif; } .sidebar{ position: fixed; left: 0; top: 0; height: 100%; width: 78px; background: #003b46; padding: 6px 14px; z-index: 99; transition: all 0.5s ease; } .sidebar.open{ width: 250px; } .sidebar .logo-details{ height: 60px; display: flex; align-items: center; position: relative; } .sidebar .logo-details .icon{ opacity: 0; transition: all 0.5s ease; } .sidebar .logo-details .logo_name{ color: #fff; font-size: 20px; font-weight: 600; opacity: 0; transition: all 0.5s ease; } .sidebar.open .logo-details .icon, .sidebar.open .logo-details .logo_name{ opacity: 1; } .sidebar .logo-details #btn{ position: absolute; top: 50%; right: 0; transform: translateY(-50%); font-size: 22px; transition: all 0.4s ease; font-size: 23px; text-align: center; cursor: pointer; transition: all 0.5s ease; } .sidebar.open .logo-details #btn{ text-align: right; } .sidebar i{ color: #fff; height: 60px; min-width: 50px; font-size: 28px; text-align: center; line-height: 60px; } .sidebar .nav-list{ margin-top: 20px; height: 100%; } .sidebar li{ position: relative; margin: 8px 0; list-style: none; } .sidebar li .tooltip{ position: absolute; top: -20px; left: calc(100% + 15px); z-index: 3; background: #fff; box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3); padding: 6px 12px; border-radius: 4px; font-size: 15px; font-weight: 400; opacity: 0; white-space: nowrap; pointer-events: none; transition: 0s; } .sidebar li:hover .tooltip{ opacity: 1; pointer-events: auto; transition: all 0.4s ease; top: 50%; transform: translateY(-50%); } .sidebar.open li .tooltip{ display: none; } .sidebar input{ font-size: 15px; color: #FFF; font-weight: 400; outline: none; height: 50px; width: 100%; width: 50px; border: none; border-radius: 12px; transition: all 0.5s ease; background: #003b46; } .sidebar.open input{ padding: 0 20px 0 50px; width: 100%; } .sidebar .bx-search{ position: absolute; top: 50%; left: 0; transform: translateY(-50%); font-size: 22px; background: #003b46; color: #FFF; } .sidebar.open .bx-search:hover{ background: #003b46; color: #FFF; } .sidebar .bx-search:hover{ background: #FFF; color: #002d35; } .sidebar li a{ display: flex; height: 100%; width: 100%; border-radius: 12px; align-items: center; text-decoration: none; transition: all 0.4s ease; background: #003b46; } .sidebar li a:hover{ background: #FFF; } .sidebar li a .links_name{ color: #fff; font-size: 15px; font-weight: 400; white-space: nowrap; opacity: 0; pointer-events: none; transition: 0.4s; } .sidebar.open li a .links_name{ opacity: 1; pointer-events: auto; } .sidebar li a:hover .links_name, .sidebar li a:hover i{ transition: all 0.5s ease; color: #002a31; } .sidebar li i{ height: 50px; line-height: 50px; font-size: 18px; border-radius: 12px; } .sidebar li.profile{ position: fixed; height: 60px; width: 78px; left: 0; bottom: -8px; padding: 10px 14px; background: #685000; transition: all 0.5s ease; overflow: hidden; } .sidebar.open li.profile{ width: 250px; } .sidebar li .profile-details{ display: flex; align-items: center; flex-wrap: nowrap; } .sidebar li img{ height: 45px; width: 45px; object-fit: cover; border-radius: 6px; margin-right: 10px; } .sidebar li.profile .name, .sidebar li.profile .job{ font-size: 15px; font-weight: 400; color: #fff; white-space: nowrap; } .sidebar li.profile .job{ font-size: 12px; } .sidebar .profile #log_out{ position: absolute; top: 50%; right: 0; transform: translateY(-50%); background: #003b46; width: 100%; height: 60px; line-height: 60px; border-radius: 0px; transition: all 0.5s ease; } .sidebar.open .profile #log_out{ width: 50px; background: none; } .home-section{ position: relative; background: #E4E9F7; min-height: 100vh; top: 0; left: 78px; width: calc(100% - 78px); transition: all 0.5s ease; z-index: 2; } .sidebar.open ~ .home-section{ left: 250px; width: calc(100% - 250px); } .home-section .text{ display: inline-block; color: #003b46; font-size: 25px; font-weight: 500; margin: 18px } @media (max-width: 420px) { .sidebar li .tooltip{ display: none; } }
JavaScript
Here is the complete code for script.js file to function the menu:
let sidebar = document.querySelector(".sidebar"); let closeBtn = document.querySelector("#btn"); let searchBtn = document.querySelector(".bx-search"); closeBtn.addEventListener("click", ()=>{ sidebar.classList.toggle("open"); menuBtnChange();//calling the function(optional) }); searchBtn.addEventListener("click", ()=>{ // Sidebar open when you click on the search iocn sidebar.classList.toggle("open"); menuBtnChange(); //calling the function(optional) }); // following are the code to change sidebar button(optional) function menuBtnChange() { if(sidebar.classList.contains("open")){ closeBtn.classList.replace("bx-menu", "bx-menu-alt-right");//replacing the iocns class }else { closeBtn.classList.replace("bx-menu-alt-right","bx-menu");//replacing the iocns class } }
Download Source Code
You can download this source code with no copyright using the button below. The code is totally free and compiled to be used right away, allowing to enhance your website with a trendy and useful navigation bar.
Conclusion
This Responsive Side Navigation Bar With Tooltips in HTML, CSS, and JavaScript is very useful and can give your site an improved professional navigation menu.
You can use them in your projects, free of charge with the condition that you give credit to JV Source Codes by linking back to this site.
To watch more lessons, click on the subscribe button like it was done for this video and if you have any questions, feel free to write a message in the comments section and I’ll check it out.