React Navbar - Flowbite
The navbar component is an important section of any website as it is the first section that appears on any page and it serves the purpose of allowing your users to navigate throughout your website.
Generally, the navigation bar consists of the logo of your website, a list of menu items for navigation and other secondary elements such as buttons, dropdowns, and a hamburger menu for mobile devices.
All interactivity and options are handled by using React properties and you can customise the appearance of the navbar using the classes from Tailwind CSS.
To start using the navbar component you need to import it from Flowbite React:
import { Navbar } from "flowbite-react";
Default navbar#
Use the default navbar component to showcase the logo and a list of menu items with links to other pages of your website by adding the <NavbarBrand> and <NavbarLink> components inside the <Navbar> component.
On mobile device the navigation bar will be collapsed and you will be able to use the hamburger menu to toggle the menu items by adding the <NavbarToggle> component.
Navbar with CTA button#
Use this example to show a CTA button inside the navbar component for marketing advantages and to increase the conversion rate of your website.
Navbar with dropdown#
Use this example to feature a dropdown menu when clicking on the user avatar inside the navbar by importing the <Avatar> and <Dropdown> components.
Theme#
To learn more about how to customize the appearance of components, please see the Theme docs.
{
"root": {
"base": "bg-white px-2 py-2.5 sm:px-4 dark:border-gray-700 dark:bg-gray-800",
"rounded": {
"on": "rounded",
"off": ""
},
"bordered": {
"on": "border",
"off": ""
},
"inner": {
"base": "mx-auto flex flex-wrap items-center justify-between",
"fluid": {
"on": "",
"off": "container"
}
}
},
"brand": {
"base": "flex items-center"
},
"collapse": {
"base": "w-full md:block md:w-auto",
"list": "mt-4 flex flex-col md:mt-0 md:flex-row md:space-x-8 md:text-sm md:font-medium",
"hidden": {
"on": "hidden",
"off": ""
}
},
"link": {
"base": "block py-2 pl-3 pr-4 md:p-0",
"active": {
"on": "bg-primary-700 text-white md:bg-transparent md:text-primary-700 dark:text-white",
"off": "border-b border-gray-100 text-gray-700 hover:bg-gray-50 md:border-0 md:hover:bg-transparent md:hover:text-primary-700 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent md:dark:hover:text-white"
},
"disabled": {
"on": "text-gray-400 hover:cursor-not-allowed dark:text-gray-600",
"off": ""
}
},
"toggle": {
"base": "inline-flex items-center rounded-lg p-2 text-sm text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 md:hidden dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600",
"icon": "h-6 w-6 shrink-0",
"title": "sr-only"
}
}