Navbar
A navigation bar (or navigation system) is a section of a graphical user interface intended to aid visitors in accessing information.

Usage
The navbar uses a custom hook useSidebar for the side menu on mobile devices.
npm i react-hartan
import { Navbar } from "react-hartan"
function App() {
return (
<>
<Navbar></Navbar>
</>
)
}
export default AppCustomization With Props
navList-> Accepts an array, where each element is an object of the structure:
{
elem: <></>, // element
}
// By default it is an HTML <a></a> element with no attributes specified.
// This prop will be helpful in case you want to add <Link></Link> or <NavLink></NavLink> component from react-router and if you want anchor only you will still need to specify the attributes like href (basically declare the full element and pass it).statesObj-> Used to show/hide various parts of Navbar, accepts an object of the structure:
{
logo: {
full: true, // boolean
img: true, // boolean
name: true, // boolean
},
buttonState: true, // boolean
}
// above are default values for this object and can be changedonClickFunction-> Accepts a function, written by the user, for handling on Click logic on button.buttonText-> Accepts a string/node value, used as the button name.logoImgSrc-> Accepts a string value, the image source link used as logo in Navbar.logoName-> Accepts a string/node value, used as the text beside the logo image.id-> The id prop is similar to the id attribute in HTML. It allows to provide overall component id.imgLoad-> The imgLoad prop is mapped to the loading attribute in HTML img tag. It allows to provide overall the value for loading attribute, "lazy" | "eager".userHeaderStyle-> Accepts the class name(s) as string, custom styling prop for the full navbar container.userNavListStyle-> Accepts the class name(s) as string, custom styling prop for container for list items shown.userNavListItemStyle-> Accepts the class name(s) as string, custom styling prop for each list item inside the list container.userLogoStyle-> Accepts the class name(s) as string, custom styling prop for the container having the logo image and logo text.userSideBarStyle-> Accepts the class name(s) as string, custom styling prop for the sidebar shown only on mobile devices.userButtonStyle-> Accepts the class names(s) as string, custom styling prop for the button.userNavButtonSvgColor-> Accepts class name as string, mainly the fill color property to change the color of menu button shown on mobile devices.
import { Navbar } from "react-hartan"
function App() {
return (
<>
<Navbar></Navbar>
</>
)
}
export default App// App.css
.my-class{
font-size: 2rem;
background-color: red;
padding: 1rem;
}
.bg-red{
padding: 2rem;
background-color: red;
}
.bg-pink{
background-color: pink;
}
// App.jsx
import { Navbar } from "react-hartan"
function App() {
const imgSrc = "/hartan.png";
return (
<>
<Navbar userNavListStyle={"my-class"} userNavListItemStyle={"bg-pink"} userSideBarStyle={"bg-pink"} logoImgSrc={imgSrc}></Navbar>
</>
)
}
export default AppComponent Code
This is the code for the Navbar component.
Last updated