Skip to content

Enisson/responsive-navbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hamburguer menu React Js

This is a simple project I've made to show how a hamburger menu works in React Js.

navBar

The Project

First, I created the project design on the figma platform

image

How it works

I created a folder in component where I will put the files that will be responsible for the menu

image

In the NavLinks file I put the html of the navigation menu

image

And I imported this file in both MobileNavigaiton and Navigation. the MobileNavigation file will be responsible for the mobile settings while the Navigation file will be responsible for the web settings.

I import both Mobile Navigation and Navigation files in the Navbar file. The Navbar file will be responsible for rendering both.

image

Mobile Configuration

In the MobileNavigation file I make use of useState which will tell me the state of the menu.

image

then I import the images that I will use for the hamburger menu. I created a click event that calls an anonymous function and changes between true and false each time this event is called

image

I make use of the ternary operator to know if the menu is open or not. if true, show const closeIcon on screen and if false, show const hamburguerIcon instead.

image

When the hamburger menu is activated, clicking on the navigation menus will not close the menu. To solve this problem I made use of props. I created a function called closeMobileMenu that will pass the value of open to false.

image

And pass some parameters to the NavLinks file

image

And I pass these parameters through a click event inside the NavLinks file on each li.

image

About

a responsive navigation bar made with react js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published