Skip to content

Navbar

The Navbar component provides a flexible navigation bar with support for logos, navigation menus, and action buttons. It includes optional sticky behavior for enhanced user experience.

You can preview the Navbar component in action on the Playground.

<nav class="navbar">
<div class="navbar-logo">logo</div>
<div class="navbar-nav">
<ul class="navbar-menu">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div class="navbar-actions">actions</div>
</nav>

Navbar component is made with multiple sub-components to provide flexibility and customization options. To cerate a navbar you need to use the following components:

---
import {
Navbar,
NavbarLogo,
NavbarNav,
NavbarActions,
} from "@components/navbar";
---
<Navbar>
<NavbarLogo> Logo </NavbarLogo>
<NavbarNav items={items} />
<NavbarActions> Actions </NavbarActions>
</Navbar>

To enable sticky behavior for the Navbar, use the sticky prop with the following options.

<Navbar className="my-navbar" sticky={{threshold: 100, offset: 10, stickyOnTop: false}}>
...
</Navbar>
Prop NameTypeDefaultDescription
classNamestring-Additional CSS classes for custom styling.
stickyobject-Enables sticky behavior for the navbar.
sticky.thresholdnumber100Scroll distance before sticky activates in px
sticky.offsetnumber0Top position when sticky in px
sticky.stickyOnTopbooleanfalseOnly sticky on scroll up

NavbarNav component accepts an array of navigation items via the items prop.

---
const menu = [
{ href: "#", title: "Home", class: "my-item" },
{
href: "#",
title: "Dropdown",
class: "my-dropdown",
submenu: [
{ href: "#", title: "Option 1", class: "my-subitem" },
{ href: "#", title: "Option 2", class: "my-subitem" },
{ href: "#", title: "Option 3", class: "my-subitem" },
],
},
{ href: "#", title: "About", class: "my-item" },
{ href: "#", title: "Services", class: "my-item" },
{ href: "#", title: "Contact", class: "my-item" },
];
---
<NavbarNav items={menu} />
PropTypeDefaultDescription
itemsarray[]Array of navigation items.
item.titlestring-Title of the navigation item.
item.hrefstring-URL of the navigation item.
item.targetstring-Target attribute for the link.
item.scrollstring-Scroll to specified target element,see scroll component documentation…
ite.submenuarray-Array of submenu items with same structure as items.

Navbar logo does not accept any props. You can add your logo content as children.

<NavbarLogo>
<a href="/">
<img src="/logo.png" alt="Logo" />
</a>
</NavbarLogo>

Navbar actions component does not accept any props. You can add your action buttons or links as children

<NavbarActions>
<a href="/login" class="btn btn-primary">Login</a>
</NavbarActions>
--navbar-height: 60px;
--navbar-bg: #ffffff;
--navbar-logo-width: 25%;
--navbar-actions-width: 25%;
--navbar-menu-gap: 30px;