Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Global Navigation

  • Navbar
  • BeianFooter
  • Brand
  • AppLauncher
  • Sidebar
  • NavMenu
  • NavigationMenu
  • Menu
  • Menubar
  • Dock
  • BubbleMenu
  • CardNav
  • FlowingMenu
  • GooeyNav
  • PillNav
  • StaggeredMenu

In-page Navigation

  • RouteTabs
  • Tabs
  • Breadcrumb
  • Pagination
  • Anchor
  • Affix
  • BackTop
  • Stepper
  • Steps
  • PageHeader

Actions and Tools

  • Command
  • ContextMenu
  • Toolbar
  • Accordion
  • Collapsible
  • Link
  • AnimatedThemeToggler

Navbar

navbar

Builds a responsive top navigation bar with brand, links, actions, and mobile menu.

Usage

Basic usage

NavbarBrand places the brand, NavbarContent arranges the navigation items, and isActive highlights the current page.

Hulian
  • Components
  • Documentation
  • Theme
tsx
<Navbar bordered>
  <NavbarBrand>Hulian</NavbarBrand>
  <NavbarContent justify="end">
    <NavbarItem isActive>Component</NavbarItem>
    <NavbarItem>Documentation</NavbarItem>
    <NavbarItem>Theme</NavbarItem>
  </NavbarContent>
</Navbar>

Content centered

justify of NavbarContent controls the navigation item alignment direction.

Hulian
  • Components
  • Documentation
  • Theme
tsx
<Navbar bordered>
  <NavbarBrand>Hulian</NavbarBrand>
  <NavbarContent justify="center">
    <NavbarItem isActive>Component</NavbarItem>
    <NavbarItem>Documentation</NavbarItem>
    <NavbarItem>Theme</NavbarItem>
  </NavbarContent>
</Navbar>

Responsive menu

NavbarMenuToggle controlled expansion and folding menu for narrow screen (view with narrowed window).

Hulian
  • Components
  • Documentation
  • Theme
tsx
function App() {
  const [open, setOpen] = useState(false);
  return (
    <Navbar bordered>
      <NavbarMenuToggle isOpen={open} onToggle={() => setOpen((v) => !v)} />
      <NavbarBrand>Hulian</NavbarBrand>
      <NavbarContent justify="end" className="hidden sm:flex">
        <NavbarItem isActive>Component</NavbarItem>
        <NavbarItem>Documentation</NavbarItem>
      </NavbarContent>
    </Navbar>
  );
}

Compact navbar with soft pill items

size="sm" shrinks the bar to 56px and variant="page" blends it into the page background; NavbarItem variant="soft" gives the active item the accent's subtle background, and the link inside is clickable across the whole pill.

Hulian
  • Components
  • Blocks
  • Pages
tsx
<Navbar size="sm" variant="page">
  <NavbarBrand grow={false}>Hulian</NavbarBrand>
  <NavbarContent>
    <NavbarItem variant="soft" isActive><a href="#">Components</a></NavbarItem>
    <NavbarItem variant="soft"><a href="#">Blocks</a></NavbarItem>
    <NavbarItem variant="soft"><a href="#">Pages</a></NavbarItem>
  </NavbarContent>
</Navbar>

When to use

Use Navbar for a page-level top bar with branding, primary navigation, and a mobile menu toggle. It is a horizontal global header. Use NavMenu for a vertical sidebar tree, NavigationMenu for multilevel navigation with dropdown panels, or BeianFooter for a Chinese regulatory footer.

Import

ts
import { Navbar, NavbarBrand, NavbarContent, NavbarItem, NavbarMenu, NavbarMenuToggle } from "@hulianui/ui"

Props

Each subcomponent inherits the attributes of its underlying native element.

Navbar (<nav>)

NameTypeDefaultDescription
stickybooleanfalseWhether to keep the bar pinned to the top while scrolling.
borderedbooleantrueWhether to show a separator border along the bottom.
size"md" | "sm""md"Height: md is 64px (admin apps); sm is 56px, a compact bar for docs and marketing sites with tighter side padding.
variant"surface" | "page""surface"Background: surface is a translucent surface color (a panel floating over content); page is a translucent page background with a lighter separator (blends into the page). Both blur what's behind.

NavbarBrand (<div>)

NameTypeDefaultDescription
growbooleantrueWhether the brand section shares space equally with the NavbarContent sections (flex-1 basis-0). Three equal columns are what makes justify="center" land on the center of the navbar; the brand content still hugs the left via justify-start, so nothing else moves. Pass false for a fixed-width brand (shrink-0). Only the two-section layout (brand plus a justify="start" section right next to it) needs that.

NavbarContent (<ul>)

NameTypeDefaultDescription
justify"start" | "center" | "end""start"Horizontal alignment of the content. "center" centers against the whole navbar, provided the brand section grows (see above).

NavbarItem (<li>)

NameTypeDefaultDescription
isActiveboolean-Marks the current item with aria-current and active styling.
variant"text" | "soft""text"text changes only the text color; soft fills the active item with the accent's subtle background and hovered items with a neutral one. When the item holds a link directly, the padding moves onto the link so the whole pill is clickable.

NavbarMenuToggle

NameTypeDefaultDescription
isOpenbooleanfalseControlled open state.
aria-labelstringLocale value based on isOpenAccessible label. An explicit value takes precedence over ConfigProvider.
breakpoint"sm" | "md" | "lg" | "xl""sm"Hidden from this breakpoint up, where the horizontal navigation takes over.
classNamestring-Additional class name.

NavbarMenu (<ul>)

NameTypeDefaultDescription
isOpenbooleanfalseWhether the menu is open. When closed it doesn't render, so its links can't be reached with Tab.
breakpoint"sm" | "md" | "lg" | "xl""sm"Hidden from this breakpoint up; use the same value as NavbarMenuToggle.

Events

NavbarMenuToggle

EventTypeDescription
onToggle() => voidCalled when the user requests a state change.

Slots

Navbar, NavbarContent, NavbarItem, and NavbarBrand all accept children.

SlotTypeDescription
childrenReactNodeContent rendered by each container subcomponent.

Example

tsx
function Header() {
  const [open, setOpen] = useState(false);
  return (
    <Navbar sticky bordered>
      <NavbarMenuToggle isOpen={open} onToggle={() => setOpen((v) => !v)} />
      <NavbarBrand>Hulian</NavbarBrand>
      <NavbarContent justify="end" className="hidden sm:flex">
        <NavbarItem isActive>Components</NavbarItem>
        <NavbarItem>Docs</NavbarItem>
        <NavbarItem>Theme</NavbarItem>
      </NavbarContent>
    </Navbar>
  );
}

// Compact docs-site bar: page-colored background, soft pill items, collapsed below xl
<>
  <Navbar sticky size="sm" variant="page">
    <NavbarMenuToggle isOpen={open} onToggle={toggle} breakpoint="xl" />
    <NavbarBrand grow={false}>Hulian</NavbarBrand>
    <NavbarContent className="hidden xl:flex">
      <NavbarItem variant="soft" isActive><a href="/components">Components</a></NavbarItem>
      <NavbarItem variant="soft"><a href="/blocks">Blocks</a></NavbarItem>
    </NavbarContent>
  </Navbar>
  <NavbarMenu isOpen={open} breakpoint="xl">
    <NavbarItem variant="soft" isActive><a href="/components">Components</a></NavbarItem>
    <NavbarItem variant="soft"><a href="/blocks">Blocks</a></NavbarItem>
  </NavbarMenu>
</>

Usage guidelines

  • NavbarMenuToggle and NavbarMenu are controlled: keep isOpen and onToggle in application state. Give both the same breakpoint, matching the breakpoint where the horizontal NavbarContent appears; otherwise widening the window shows the horizontal and vertical menus at once.
  • Without an explicit aria-label, the mobile toggle follows ConfigProvider locale: enUS provides “Open menu” and “Close menu”, while the no-provider fallback remains Chinese. An explicit aria-label always wins.
  • The three-section layout (brand + centered menu + trailing actions) is the default shape: NavbarBrand grows by default so all three sections are equal and the centered one truly sits at the navbar center. A two-section layout (brand plus a justify="start" section next to it) must pass grow={false}, otherwise that section is pushed to the one-third mark.
  • To let the brand truncate on narrow screens, add min-w-0 to NavbarBrand alongside truncate: flex items default to min-width: auto and will not shrink without it.

Related

BeianFooter · NavMenu · NavigationMenu · Menu · Menubar · Dock

Playground

Hulian
  • Components
  • Documentation
  • Theme
<Navbar sticky bordered>
  <NavbarMenuToggle isOpen={open} onToggle={toggle} />
  <NavbarBrand>Hulian</NavbarBrand>
  <NavbarContent justify="end">
    <NavbarItem isActive>Component</NavbarItem>
    <NavbarItem>Documentation</NavbarItem>
  </NavbarContent>
</Navbar>
PreviousRouteTabsNavigationNextBeianFooter

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Example
    • Usage guidelines
    • Related
  • Playground