Component reference
Navbar
Brand, navigation and actions with a real responsive toggle.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Width adapts to the available space
"use client";
import { useState } from "react";
import {
Badge,
Navbar,
NavbarActions,
NavbarBrand,
NavbarContent,
NavbarItem,
NavbarToggle
} from "@pimolu/react";
export function NavbarExample() {
const [active, setActive] = useState("Overview");
return (
<div className="space-y-5">
<Navbar collapsible>
<NavbarBrand href="#navigation-example">Orbit</NavbarBrand>
<NavbarToggle openLabel="Open example menu" closeLabel="Close example menu" />
<NavbarContent aria-label="Example navigation">
{
["Overview", "Projects"].map((label) => <NavbarItem
key={label}
href="#navigation-example"
active={active === label}
onClick={(event) => { event.preventDefault(); setActive(label); }}
>
{
label
}
</NavbarItem>)
}
</NavbarContent>
<NavbarActions>
<Badge variant="success">Workspace</Badge>
</NavbarActions>
</Navbar>
<p id="navigation-example" role="status">Current view: {active}.</p>
</div>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Surface treatments
Choose a surface, blend into the page, or use a floating frame. The transparent appearance avoids side edges caused by an inset background.
Basic
Brand, links and actions; the active link is marked for assistive technology.
Mobile menu
Both examples use the same Navbar API. Open the menu to see links and actions; selecting a link closes it. The layout responds to the navbar's own width.
Usage
Compose NavbarBrand, NavbarContent, NavbarItem and NavbarActions. Enable collapsible and include NavbarToggle for narrow containers. Choose appearance=surface, transparent or floating; bordered controls the bottom divider while floating keeps its surrounding frame.
NavbarToggle accepts custom icon and closeIcon nodes. Control open/onOpenChange when route changes or another part of your app should close the menu.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluNavbarProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
appearance | "surface" | "transparent" | "floating" | undefined | surface; transparent inherits the page background | Surface treatment. Defaults to surface; transparent inherits the page background. |
sticky | boolean | undefined | false | Stick to the top of the scroll container. |
bordered | boolean | undefined | true | Draw the bottom border. Defaults to true. |
itemsPosition | "left" | "right" | "center" | undefined | "left" | Alignment of the navigation items inside the bar. Defaults to "left". The brand stays at the start and the actions at the end. |
collapsible | boolean | undefined | false | Collapse links and actions behind NavbarToggle in narrow containers. |
open | boolean | undefined | — | Controlled mobile menu state. |
defaultOpen | boolean | undefined | false | Initial mobile menu state when uncontrolled. |
onOpenChange | ((open: boolean) => void) | undefined | — | Public Pimolu prop; see the source declaration for details. |
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onChange | ChangeEventHandler<HTMLElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLElement> | undefined | — | Standard React/HTML attribute. |
appearance"surface" | "transparent" | "floating" | undefinedDefault: surface; transparent inherits the page background
Surface treatment. Defaults to surface; transparent inherits the page background.
stickyboolean | undefinedDefault: false
Stick to the top of the scroll container.
borderedboolean | undefinedDefault: true
Draw the bottom border. Defaults to true.
itemsPosition"left" | "right" | "center" | undefinedDefault: "left"
Alignment of the navigation items inside the bar. Defaults to "left". The brand stays at the start and the actions at the end.
collapsibleboolean | undefinedDefault: false
Collapse links and actions behind NavbarToggle in narrow containers.
openboolean | undefinedNo default extracted.
Controlled mobile menu state.
defaultOpenboolean | undefinedDefault: false
Initial mobile menu state when uncontrolled.
onOpenChange((open: boolean) => void) | undefinedNo default extracted.
Public Pimolu prop; see the source declaration for details.
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onChangeChangeEventHandler<HTMLElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLElement> | undefinedNo default extracted.
Standard React/HTML attribute.
PimoluNavbarBrandProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
type | string | undefined | "button" | Standard React/HTML attribute. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onChange | ChangeEventHandler<HTMLAnchorElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLAnchorElement> | undefined | — | Standard React/HTML attribute. |
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
typestring | undefinedDefault: "button"
Standard React/HTML attribute.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onChangeChangeEventHandler<HTMLAnchorElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLAnchorElement> | undefinedNo default extracted.
Standard React/HTML attribute.
PimoluNavbarContentProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
aria-label | string | undefined | — | Accessible name of the navigation landmark. |
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
onChange | ChangeEventHandler<HTMLElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLElement> | undefined | — | Standard React/HTML attribute. |
aria-labelstring | undefinedNo default extracted.
Accessible name of the navigation landmark.
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
onChangeChangeEventHandler<HTMLElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLElement> | undefinedNo default extracted.
Standard React/HTML attribute.
PimoluNavbarToggleProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
icon | ReactNode | — | Replaces the default hamburger icon. |
closeIcon | ReactNode | — | Replaces the default close icon. |
openLabel | string | undefined | "Open menu" | Accessible label while the menu is closed. |
closeLabel | string | undefined | "Close menu" | Accessible label while the menu is open. |
onChange | ChangeEventHandler<HTMLButtonElement, Element> | undefined | — | Standard React/HTML attribute. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onClick | MouseEventHandler<HTMLButtonElement> | undefined | — | Standard React/HTML attribute. |
disabled | boolean | undefined | false | Standard React/HTML attribute. |
name | string | undefined | — | Standard React/HTML attribute. |
type | "submit" | "reset" | "button" | undefined | "button" | Standard React/HTML attribute. |
value | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
iconReactNodeNo default extracted.
Replaces the default hamburger icon.
closeIconReactNodeNo default extracted.
Replaces the default close icon.
openLabelstring | undefinedDefault: "Open menu"
Accessible label while the menu is closed.
closeLabelstring | undefinedDefault: "Close menu"
Accessible label while the menu is open.
onChangeChangeEventHandler<HTMLButtonElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onClickMouseEventHandler<HTMLButtonElement> | undefinedNo default extracted.
Standard React/HTML attribute.
disabledboolean | undefinedDefault: false
Standard React/HTML attribute.
namestring | undefinedNo default extracted.
Standard React/HTML attribute.
type"submit" | "reset" | "button" | undefinedDefault: "button"
Standard React/HTML attribute.
valuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
PimoluNavbarItemProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
active | boolean | undefined | false | Public Pimolu prop; see the source declaration for details. |
disabled | boolean | undefined | false | Public Pimolu prop; see the source declaration for details. |
icon | ReactNode | — | Decorative icon displayed before the link label. |
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
type | string | undefined | "button" | Standard React/HTML attribute. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onChange | ChangeEventHandler<HTMLAnchorElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLAnchorElement> | undefined | — | Standard React/HTML attribute. |
activeboolean | undefinedDefault: false
Public Pimolu prop; see the source declaration for details.
disabledboolean | undefinedDefault: false
Public Pimolu prop; see the source declaration for details.
iconReactNodeNo default extracted.
Decorative icon displayed before the link label.
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
typestring | undefinedDefault: "button"
Standard React/HTML attribute.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onChangeChangeEventHandler<HTMLAnchorElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLAnchorElement> | undefinedNo default extracted.
Standard React/HTML attribute.
PimoluNavbarActionsProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
childrenRequired | ReactNode | — | Public Pimolu prop; see the source declaration for details. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLDivElement> | undefined | — | Standard React/HTML attribute. |
childrenRequiredReactNodeNo default extracted.
Public Pimolu prop; see the source declaration for details.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onChangeChangeEventHandler<HTMLDivElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLDivElement> | undefinedNo default extracted.
Standard React/HTML attribute.
Accessibility
- Give navigation a useful accessible name and use real href destinations.
- Keep open/close labels clear when replacing the hamburger icon. active items identify the current page.