Skip to content
v0.9.1
Layout

Navbar

The header of a website: logo, links with dropdowns, and buttons. One piece of markup works on every screen: when there isn't room, the links fold into a panel that slides in from the side, opened by a ☰ button.

Navbar

Wide enough (768px of its own width, not the screen's), everything sits in one row. The current page's link gets aria-current="page" and an underline.

<header class="navbar">
  <div class="navbar-inner">
    <a class="navbar-brand" href="#"><span class="navbar-mark"><i class="mi mi-letter-m mi-stroke-2.5" aria-hidden="true"></i></span>Momo</a>
    <button class="navbar-toggle" type="button" aria-label="Menu"><i class="mi mi-menu" aria-hidden="true"></i><i class="mi mi-x" aria-hidden="true"></i></button>
    <div class="navbar-menu">
      <nav class="navbar-nav" aria-label="Main">
        <a class="navbar-link" href="#" aria-current="page">Home</a>
        <details class="navbar-dropdown">
          <summary class="navbar-link">Product <i class="mi mi-chevron-down navbar-caret" aria-hidden="true"></i></summary>
          <div class="navbar-dropdown-menu">
            <a href="#"><i class="mi mi-layout-dashboard" aria-hidden="true"></i><span><b>Dashboards</b><small>Stats, charts and tables</small></span></a>
            <a href="#"><i class="mi mi-layout-kanban" aria-hidden="true"></i><span><b>Boards</b><small>Kanban with drag and drop</small></span></a>
            <a href="#"><i class="mi mi-calendar" aria-hidden="true"></i><span><b>Calendar</b><small>Months, weeks and ranges</small></span></a>
          </div>
        </details>
        <a class="navbar-link" href="#">Pricing</a>
        <a class="navbar-link" href="#">Blog</a>
      </nav>
      <div class="navbar-actions">
        <a class="btn btn-ghost" href="#">Sign in</a>
        <a class="btn btn-brand" href="#">Get started</a>
      </div>
    </div>
  </div>
</header>

On a phone

Here the same navbar sits in a narrow box, so it folds. Press ☰: the panel slides in, Esc or a tap outside closes it, and so does picking a link. Dropdowns open in place inside the panel.

<div class="max-w-sm mx-auto box p-0 overflow-hidden">
  <header class="navbar">
    <div class="navbar-inner">
      <a class="navbar-brand" href="#"><span class="navbar-mark"><i class="mi mi-letter-m mi-stroke-2.5" aria-hidden="true"></i></span>Momo</a>
      <button class="navbar-toggle" type="button" aria-label="Menu"><i class="mi mi-menu" aria-hidden="true"></i><i class="mi mi-x" aria-hidden="true"></i></button>
      <div class="navbar-menu">
        <div class="navbar-menu-head"><b>Menu</b><button class="btn btn-icon btn-sm btn-ghost" type="button" data-momo-close aria-label="Close menu"><i class="mi mi-x" aria-hidden="true"></i></button></div>
        <nav class="navbar-nav" aria-label="Main (phone)">
          <a class="navbar-link" href="#" aria-current="page">Home</a>
          <details class="navbar-dropdown">
            <summary class="navbar-link">Product <i class="mi mi-chevron-down navbar-caret" aria-hidden="true"></i></summary>
            <div class="navbar-dropdown-menu">
              <a href="#"><i class="mi mi-layout-dashboard" aria-hidden="true"></i><span><b>Dashboards</b><small>Stats, charts and tables</small></span></a>
              <a href="#"><i class="mi mi-layout-kanban" aria-hidden="true"></i><span><b>Boards</b><small>Kanban with drag and drop</small></span></a>
            </div>
          </details>
          <a class="navbar-link" href="#">Pricing</a>
          <a class="navbar-link" href="#">Blog</a>
        </nav>
        <div class="navbar-actions">
          <a class="btn btn-ghost" href="#">Sign in</a>
          <a class="btn btn-brand" href="#">Get started</a>
        </div>
      </div>
    </div>
  </header>
  <div class="p-6 text-sm text-muted">Page content…</div>
</div>

Give the panel a .navbar-menu-head: a top row with a title and a close button (data-momo-close). The panel covers the ☰ button, so this is the visible way to close it on a phone. The row is hidden when the navbar is wide. A tap outside the panel only closes it; it never clicks the page underneath.

Floating

.navbar-float turns the navbar into a card: a gap around it, rounded corners and a line all the way round. With .navbar-sticky it stays floating at the top while the page scrolls, and its mega menus float under it at the same width. Add .shadow or .shadow-md for a hard shadow.

<header class="navbar navbar-float">
  <div class="navbar-inner">
    <a class="navbar-brand" href="#"><span class="navbar-mark"><i class="mi mi-letter-m mi-stroke-2.5" aria-hidden="true"></i></span>Momo</a>
    <button class="navbar-toggle" type="button" aria-label="Menu"><i class="mi mi-menu" aria-hidden="true"></i><i class="mi mi-x" aria-hidden="true"></i></button>
    <div class="navbar-menu">
      <div class="navbar-menu-head"><b>Menu</b><button class="btn btn-icon btn-sm btn-ghost" type="button" data-momo-close aria-label="Close menu"><i class="mi mi-x" aria-hidden="true"></i></button></div>
      <nav class="navbar-nav" aria-label="Main (floating)">
        <a class="navbar-link" href="#" aria-current="page">Home</a>
        <a class="navbar-link" href="#">Features</a>
        <a class="navbar-link" href="#">Pricing</a>
      </nav>
      <div class="navbar-actions"><a class="btn btn-brand" href="#">Get started</a></div>
    </div>
  </div>
</header>
<header class="navbar navbar-float navbar-ink navbar-center shadow-md mt-6">
  <div class="navbar-inner">
    <a class="navbar-brand" href="#"><span class="navbar-mark"><i class="mi mi-letter-m mi-stroke-2.5" aria-hidden="true"></i></span>Momo</a>
    <button class="navbar-toggle" type="button" aria-label="Menu"><i class="mi mi-menu" aria-hidden="true"></i><i class="mi mi-x" aria-hidden="true"></i></button>
    <div class="navbar-menu">
      <div class="navbar-menu-head"><b>Menu</b><button class="btn btn-icon btn-sm btn-ghost" type="button" data-momo-close aria-label="Close menu"><i class="mi mi-x" aria-hidden="true"></i></button></div>
      <nav class="navbar-nav" aria-label="Main (floating, dark)">
        <a class="navbar-link" href="#">Work</a>
        <a class="navbar-link" href="#" aria-current="page">About</a>
        <a class="navbar-link" href="#">Contact</a>
      </nav>
      <div class="navbar-actions"><a class="btn btn-sm btn-brand" href="#">Hire me</a></div>
    </div>
  </div>
</header>

Change the gap, the widest size and the corners with --navbar-float-gap (12px), --navbar-float-max (1216px) and --navbar-float-radius.

Sticky, see-through, hiding

See them on the landing example (it uses .navbar-sticky):

ClassDoes
.navbar-stickyStays at the top while the page scrolls; gets .is-scrolled once the page has moved. Anchor links (#features) land below it.
.navbar-transparentSee-through at the top of the page (over a hero), solid once scrolled
.navbar-autohideSlides away while scrolling down, comes back when scrolling up
.navbar-fixedFixed at the top over the page: give the page padding-top: var(--momo-navbar-h)

Momo publishes the height of a sticky or fixed navbar as --momo-navbar-h on <html>. A full-screen hero under it uses it: .hero-full { --hero-offset: var(--momo-navbar-h); }.

Looks and folding

<header class="navbar navbar-ink navbar-center">
  <div class="navbar-inner">
    <a class="navbar-brand" href="#"><span class="navbar-mark"><i class="mi mi-letter-m mi-stroke-2.5" aria-hidden="true"></i></span>Momo</a>
    <button class="navbar-toggle" type="button" aria-label="Menu"><i class="mi mi-menu" aria-hidden="true"></i><i class="mi mi-x" aria-hidden="true"></i></button>
    <div class="navbar-menu">
      <nav class="navbar-nav" aria-label="Main (ink)">
        <a class="navbar-link" href="#">Features</a>
        <a class="navbar-link" href="#" aria-current="page">Pricing</a>
        <a class="navbar-link" href="#">Customers</a>
      </nav>
      <div class="navbar-actions"><a class="btn btn-sm btn-brand" href="#">Get started</a></div>
    </div>
  </div>
</header>
ClassDoes
.navbar-surface / .navbar-inkWhite / dark background (the page color by default)
.navbar-plainNo line under it
.navbar-floatA floating card with a gap around it
.navbar-centerLinks in the middle
.navbar-expand-lgFolds below 1024px instead of 768px (many links)
.navbar-expand-neverNever folds (two or three short links)
.navbar-dropdown-menu.is-wideA two-column dropdown; .is-end lines it up on the right

Put the content in .navbar-inner.container to line the navbar up with the page's container.

Accessibility

Start

OverviewStart Getting startedStart CustomizeStart

Guides

AccessibilityGuides BreakpointsGuides ChangelogGuides Customize componentsGuides JavaScriptGuides MotionGuides OptimizeGuides PhonesGuides RebootGuides Right-to-left (RTL)Guides Stacking orderGuides Using Momo with AIGuides

Foundations

ColorsFoundations TypographyFoundations ProseFoundations Images & figuresFoundations CodeFoundations Lines & shadowsFoundations Dark modeFoundations

Forms

Checkbox & switchForms ComboboxForms Date pickerForms Date rangeForms Fields & labelsForms File uploadForms Floating labelsForms Number stepperForms PasswordForms PIN codeForms RatingForms SelectForms SliderForms Tag inputForms Time pickerForms ValidationForms

Components

AccordionComponents Alert & bannerComponents AvatarComponents BadgeComponents BreadcrumbComponents ButtonComponents Button groupComponents CalendarComponents CardComponents CarouselComponents ChartsComponents ChipsComponents CollapseComponents Command paletteComponents CommentsComponents Confirm dialogsComponents Cookie bannerComponents Data tableComponents Description listComponents Dialog & toastComponents DividerComponents DrawerComponents Dropdown menuComponents Empty stateComponents File managerComponents Filter & sortComponents Gallery & lightboxComponents Inbox & chatComponents Infinite scrollComponents KanbanComponents Keyboard shortcutsComponents List groupComponents MarqueeComponents Media objectComponents Nav overflowComponents Notification centerComponents PaginationComponents ProgressComponents Pull to refreshComponents SkeletonComponents SortableComponents SpinnerComponents Split viewComponents Stat cardComponents Steps & wizardComponents Swipe actionsComponents TableComponents TabsComponents TimelineComponents TogglerComponents Tooltip & popoverComponents TourComponents Tree viewComponents VideoComponents WhiteboardComponents

Layout

Announcement barLayout App shellLayout Back to topLayout Container & sectionLayout ExamplesLayout FooterLayout HeroLayout JumbotronLayout Mega menuLayout NavbarLayout Site sidebarLayout

Sections

Bento gridSections Blog cardsSections Call to actionSections Contact & newsletterSections FAQSections FeaturesSections Logo cloudSections PricingSections TeamSections TestimonialsSections

Utilities

OverviewUtilities State variantsUtilities Display & flexUtilities Grid & gapUtilities SpacingUtilities SizingUtilities TextUtilities Links & color strengthUtilities Position & overflowUtilities BackgroundsUtilities Borders & effectsUtilities Transforms & filtersUtilities InteractionsUtilities

Helpers

Fixed, sticky & frostedHelpers Hover & focusHelpers Hover revealHelpers Icon linkHelpers PrintHelpers Relative timeHelpers Screen reader textHelpers Scroll inHelpers ScrollspyHelpers Share buttonHelpers Skip linkHelpers StacksHelpers Stretched linkHelpers Theme toggleHelpers Truncated textHelpers

Page patterns

404 pagePage patterns Coming soonPage patterns Login & registerPage patterns SettingsPage patterns ProfilePage patterns CRM contactsPage patterns ProjectsPage patterns File manager pagePage patterns Billing & plansPage patterns Help centerPage patterns Mobile app screensPage patterns
↑ ↓ moveEnter openEsc close