Skip to content
synccn

Menubar

Desktop-style File, Edit, View menus with arrow-key travel.

Installation

$ pnpm dlx shadcn@latest add @synccn/menubar

First time in this project? Connect synccn with one command.

Usage

import { Menubar } from "@/components/ui/menubar";<Menubar menus={menus} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

Menubar

Desktop-app style menu bar. Once one menu is open, hovering the others switches between them; Left/Right arrows move along the bar. menus: [{ label, items: [...same item shape as DropdownMenu] }]

  • menusrequired
    MenubarMenu[]

    Top-level menus, left to right.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseClickOutside (closes on an outside click), useEscape (closes on Escape)

npm packages

Keyboard

  • ←or→Move between top-level menus
  • ↓Open the focused menu
  • EscClose the open menu

Accessibility

  • Uses menubar, menu and menuitem roles; triggers report aria-expanded and aria-haspopup.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: it, menu, menubar, menuitem
  • ARIA attributes: aria-checked, aria-expanded, aria-haspopup
  • Keys handled: ArrowDown, ArrowLeft, ArrowRight
  • Closes with Escape
  • Closes when you click or tap outside
  • Shows a visible focus ring for keyboard users