codefast/ui

Command Palette

Search for a command to run...

Source
Navigation

Menubar

Horizontal menu bar with dropdowns, checkboxes, radio items, and keyboard navigation.

Examples

Usage

The minimal import and composition — see Examples below for styled, real-world variants.

15 lines
import { Menubar, MenubarContent, MenubarItem, MenubarMenu, MenubarTrigger } from "@codefast/ui/menubar";

export function MenubarUsage() {
  return (
    <Menubar>
      <MenubarMenu>
        <MenubarTrigger>File</MenubarTrigger>
        <MenubarContent>
          <MenubarItem>New Tab</MenubarItem>
          <MenubarItem>New Window</MenubarItem>
        </MenubarContent>
      </MenubarMenu>
    </Menubar>
  );
}

Anatomy

How the parts nest — every slot the component exposes, in composition order.

Menubar
└── MenubarMenu
├── MenubarTrigger
└── MenubarContent
└── MenubarItem
└── MenubarShortcut

Features

  • Multiple MenubarMenu siblings share roving focus — Left/Right arrow moves between top-level menus, Down opens the focused one.
  • Supports the same item types as Dropdown Menu and Context Menu — checkbox items, a radio group, submenus, and destructive variants.
  • Best suited to desktop; on mobile or touch, prefer a Dropdown Menu or Sheet instead.

API reference

Props for each part of the component. All native element props are also forwarded.

Menubar

The horizontal bar that hosts roving focus across its top-level menus.

valuestring

Controlled value of the currently open menu.

defaultValuestring

Uncontrolled initial value of the open menu.

onValueChange(value: string) => void

Called when the open menu changes.

loopboolean

Whether arrow-key navigation loops from the last menu back to the first.

childrenReactNode

One MenubarMenu per top-level menu (File, Edit…).

MenubarMenu

One top-level menu — pairs a MenubarTrigger with its MenubarContent.

valuestring

Identifies this menu; required when Menubar's value/onValueChange are controlled.

childrenReactNode

A MenubarTrigger and its MenubarContent.

MenubarItem

A single command row inside MenubarContent.

insetboolean

Adds start padding to align with items that have an icon or indicator.

Defaultfalse

variant"default" | "destructive"

Use destructive for irreversible actions.

Default"default"

childrenReactNode

Label text, optionally followed by a MenubarShortcut.

MenubarShortcut

Right-aligned key-hint text within a MenubarItem.

childrenReactNode

The shortcut label, e.g. '⌘S'.

Accessibility

Built to be keyboard-navigable and screen-reader friendly out of the box.

KeyFunction
Arrow+LeftMoves between top-level menus.
Arrow+DownOpens / moves down a menu.
EnterActivates the focused item.
EscCloses the open menu.
  • Implements the ARIA menubar pattern with roving focus.
  • Best on desktop; on mobile prefer a Dropdown Menu or Sheet.
  • Mirror essential commands elsewhere — don’t hide them only here.

Guidelines

Conventions that keep usage consistent across an app.

Do

  • Group commands the way a desktop app would (File, Edit, View).
  • Show shortcuts so power users learn them.

Don’t

  • Don’t use a menubar as primary site navigation.
  • Don’t nest menus deeply.

Explore further

Ready to integrate?

Follow the Getting Started guide to install @codefast/ui, or browse the full component gallery.