Skip to content

Navbar

Introduction

The Navbar component provides a responsive, highly customizable navigation bar for web applications. It supports branding (text, logo, or custom element), navigation items (with dropdowns, badges, and icons), multiple color variants, alignment options, sticky positioning, and mobile collapsible menus. Designed for marketing sites, dashboards, e-commerce, documentation, and portfolios, the Navbar adapts to a wide range of use cases.

Import

ts
import { Navbar } from '@odyssee/components';

LiveCodeEditor examples

Basic Navbar

Code Éditable
Résultat
Code Éditable
Résultat
Code Éditable
Résultat

Variants

Code Éditable
Résultat

Alignment

Code Éditable
Résultat
Code Éditable
Résultat

Use Case: Marketing Website Navbar

Code Éditable
Résultat

Props

PropTypeDefaultDescription
brandstring | Navbar.BrandBrand section: text, logo, link, or custom element.
itemsNavbar.Item[][]Array of navigation items (see below for structure).
childrenHTMLElement | HTMLElement[]Custom children (alternative to items).
variant"default" | "dark" | "primary" | "transparent""default"Color variant for the navbar.
alignment"left" | "center" | "right""right"Alignment of navigation items.
collapsiblebooleantrueEnables mobile collapsible menu.
collapseBreakpoint"sm" | "md" | "lg" | "xl""sm"Breakpoint for showing mobile toggle.
horizontalScrollbooleanfalseEnables horizontal scroll for navigation items on mobile.
stickybooleanfalseMakes the navbar sticky at the top.
stickyOffsetstring"0"Offset from the top when sticky.
maxWidth"sm" | "md" | "lg" | "xl" | "2xl" | "full" | string"max-w-340"Max width of the navbar container.
centeredbooleantrueCenters the navbar container.
padding"sm" | "md" | "lg""md"Vertical padding for the navbar.
navClassNamestringCustom class for the nav element.
containerClassNamestringCustom class for the container.
brandClassNamestringCustom class for the brand section.
itemsClassNamestringCustom class for the items container.
toggleClassNamestringCustom class for the mobile toggle button.
onBrandClick(event: MouseEvent) => voidCallback when the brand is clicked.
onItemClick(item: Navbar.Item, index: number) => voidCallback when a navigation item is clicked.
onToggle(isOpen: boolean) => voidCallback when the mobile menu is toggled.
classNamestringAdditional CSS classes for the root element.
idstringauto-generatedID for the navbar.
styleobjectInline styles for the root element.
...restBaseComponentPropsAny other base props supported by Odyssee components.
PropTypeDescription
idstringUnique identifier for the item.
labelstring | HTMLElementItem label (text or custom element).
hrefstringLink URL.
activebooleanMarks the item as active.
disabledbooleanDisables the item.
onClick(event: MouseEvent) => voidCallback when the item is clicked.
dropdownDropdown.Item[]Array of dropdown items (same structure as Item).
badgestring | numberBadge displayed next to the item.
iconstring | HTMLElementIcon displayed next to the label.
PropTypeDescription
contentstring | HTMLElementBrand text or custom element.
hrefstringLink URL for the brand.
logostring | HTMLElementLogo (image URL, emoji, SVG, or custom element).
logoAltstringAlt text for logo image.
onClick(event: MouseEvent) => voidCallback when the brand is clicked.
classNamestringCustom class for the brand section.

Implementation notes

  • The Navbar is fully responsive, with a collapsible menu for mobile breakpoints.
  • Supports four color variants: default, dark, primary, and transparent.
  • Navigation items can include dropdowns, badges, and icons.
  • The brand section accepts text, logo, or custom elements, and can be linked.
  • Alignment (left, center, right) controls the position of navigation items.
  • Sticky positioning is supported via the sticky prop.
  • Custom classes and styles are supported for all major sections.
  • Callbacks are available for brand, item, and toggle interactions.
  • Designed for both light and dark themes.

Accessibility

  • All navigation items are rendered as accessible links or buttons.
  • The brand section uses an accessible link with aria-label.
  • Dropdown menus are keyboard navigable and support ARIA roles.
  • The mobile toggle button uses accessible SVG icons and ARIA attributes.
  • Active and disabled states are visually and programmatically indicated.
  • Sticky and collapsible behaviors do not interfere with keyboard navigation.

Best practices

  • Always provide a clear brand section for recognition and navigation.
  • Use the items prop for structured navigation; prefer dropdowns for grouped links.
  • Choose the appropriate variant for your site's theme and context.
  • Use alignment and padding to match your layout needs.
  • For mobile-heavy sites, keep navigation concise and leverage collapsible menus.
  • Use badges and icons to highlight important links or statuses.
  • Ensure all navigation items are accessible and keyboard-friendly.

Released under the MIT License.