![]() |
React Chakra UI Navigation Bar is used in every website to make it more user-friendly so that the navigation through the website becomes easy and the user can directly search for the topic of their interest. Prerequisites:We will use the following approaches to implement Navigation Bar using React Chakra UI Steps to Create React Application And Installing Module:Step 1: Create a React application using the following command: npx create-react-app gfg-navigation-app
Step 2: After creating your project folder(i.e. gfg-navigation-app), move to it by using the following command: cd gfg-navigation-app
Step 3: After creating the React application, Install the required package using the following command: npm i @chakra-ui/react @emotion/react@^11 @emotion/styled@^11 framer-motion@^6
Project Structure:The updated dependencies in the package.json file: "dependencies": { Approach 1: Navigation Bar Using Breadcrumb and LinkBox:We created the basic box having navigation components like Breadcrumb and LinkBox from the Chakra UI library and placed it for handling a header menu bar with the usual menu items as “Home”, “About”, “Contact” and “Career”. A logo is added with an image icon and a href link is used for adding links to various navigated landing web pages. Access to other links is implemented using HTML href and Chakra UI BreadcrumbLink. Example: Below example demonstrates the usage of first approach to create the navigation. Javascript
Javascript
Step to Run the application: Run the application using the following command: npm run start
Output: Now go to http://localhost:3000 in your browser: Approach 2: Navigation Bar Using Menu Components:In this approach, we have used the menu components including MenuButton, MenuList, MenuItem, and MenuDivider of ChakraUI. Example: Below example demonstrates the usage of menu component approach to create the navigation. Javascript
Steps to Run the App: npm start
Output: Now go to http://localhost:3000 in your browser: |
Reffered: https://www.geeksforgeeks.org
ReactJS |
Related |
---|
![]() |
|
|
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |