Skip to main content

Navbar Block

Navbar is a horizontal navigation bar built on MUI Stack (component="nav"), with left, center, and right regions plus link and action primitives.

Installationโ€‹

npm install @nodeblocks/frontend-navbar-block

What You Needโ€‹

ItemWhy it matters
leftContent (optional)Left region content, used by the default layout when present
centerContent (optional)Primary navigation links; omit or pass null when the center is empty
rightContent (optional)Actions such as login, Navbar.Item icons, or profile controls
Region subcomponentsNavbar.Left, Navbar.Center, Navbar.Right for compound layout
Composition modes

Pass leftContent, centerContent, and rightContent on Navbar to fill the default regions (Navbar.Left, Navbar.Center, Navbar.Right render automatically). Use compound children to replace a regionโ€™s markup while still reading root props via context (children wins over the matching *Content prop). Use a function child with blocks and blockOrder to prepend blocks or change order.

Code Examplesโ€‹

Live Editor
function Example() {
  return (
    <Navbar
      leftContent={
        <Navbar.Logo
          src="https://docs.nodeblocks.dev/img/icon-small.png"
          alt="Company Logo"
          style={{height: 32}}
        />
      }
      centerContent={
        <>
          <Navbar.Link href="#home">
            <span>Home</span>
          </Navbar.Link>
          <Navbar.Link href="#about">
            <span>About</span>
          </Navbar.Link>
          <Navbar.Link href="#services">
            <span>Services</span>
          </Navbar.Link>
          <Navbar.Link href="#contact">
            <span>Contact</span>
          </Navbar.Link>
        </>
      }
      rightContent={<Navbar.ButtonLink href="#login">Login</Navbar.ButtonLink>}
    />
  );
}
Result
Loading...

Important Propsโ€‹

Core Propsโ€‹

PropTypeRequiredDefaultDescription
leftContentReactNodeNoundefinedContent for the left region (e.g. Navbar.Logo)
centerContentReactNodeNoundefinedContent for the center region (e.g. Navbar.Link list)
rightContentReactNodeNoundefinedContent for the right region (e.g. Navbar.Item, Navbar.ButtonLink)

Content Propsโ€‹

Set leftContent, centerContent, and rightContent on the root when using the default regions. Subcomponents read them from context unless you pass children on the region (compound mode).

ComponentPropTypeRequiredDefaultDescription
LeftchildrenReactNodeNoRoot leftContentLeft region markup
LeftleftContentReactNodeNoRoot leftContentOverrides context for this region
CenterchildrenReactNodeNoRoot centerContentCenter region markup
CentercenterContentReactNodeNoRoot centerContentOverrides context for this region
RightchildrenReactNodeNoRoot rightContentRight region markup
RightrightContentReactNodeNoRoot rightContentOverrides context for this region
Logoโ€”BoxProps<'img'>No-Image logo (src, alt, style, className, etc.)
Linkโ€”StackProps<typeof Link>No-Inline nav link; pass href and label children
ButtonLinkโ€”StackProps<typeof Button>No-Contained action link; variant="contained", size="small"
ItemiconReactNodeNoundefinedIcon before label (optional badgeProps on icon)
ItemlabelReactNodeNoundefinedText label (sm+ only)
ItembadgePropsBadgePropsNoundefinedMUI Badge on icon
ItemchildrenReactNodeNoundefinedExtra content inside the control

Left, Center, Right, Logo, Link, ButtonLink, and Item are Navbar.Left, Navbar.Center, etc. Item inherits ButtonBase props (e.g. onClick).

Layout and Composition Propsโ€‹

PropTypeRequiredDefaultDescription
childrenBlocksOverride | ReactNodeNoundefinedCompound region components or function override returning blocks and blockOrder
componentReact.ElementTypeNo'nav'Root element type
classNamestringNoundefinedClass name for the root container (nbb-navbar is applied by default)
sxSxPropsNoundefinedMUI system styles for the root container

Navbar inherits StackProps<'nav'> (except children), including direction (default row), spacing (default 3 on the root), height (56 / 64 at xs / sm), horizontal padding, and bottom border. Root render order is left, center, right; defaultBlockOrder is left, center, right, logo, link, buttonLink, item.

Default UI Blocksโ€‹

BlockBuilt onNotes
Navbar (root)Stack (component="nav")direction="row", spacing={3}, height 56px (xs) / 64px (sm+)
Navbar.LeftStackdirection="row", spacing={1}
Navbar.CenterStackflexGrow: 1, spacing={2}
Navbar.RightStackjustifyContent: flex-end
Navbar.LogoBox (component="img")Logo image
Navbar.LinkStack + LinkInline nav link
Navbar.ButtonLinkStack + ButtonContained action link
Navbar.ItemButtonBase + Badge + TypographyIcon/label action; optional badge on icon

TypeScriptโ€‹

import { Navbar } from '@nodeblocks/frontend-navbar-block';
import { SettingsOutlined } from '@mui/icons-material';
import type { ReactNode } from 'react';

type NavbarRegions = {
leftContent: ReactNode;
centerContent?: ReactNode;
rightContent?: ReactNode;
};

const config: NavbarRegions = {
leftContent: (
<Navbar.Logo src="/logo.svg" alt="Company" style={{ height: 32 }} />
),
centerContent: (
<Navbar.Link href="#home">
<span>Home</span>
</Navbar.Link>
),
rightContent: <Navbar.Item icon={<SettingsOutlined />} label="Settings" />,
};

<Navbar {...config} />;