React Menubar
A glass desktop-style React menubar with File, Edit and View menus, reached with one Tab stop and walked with the arrow keys.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/menubar.jsonShopping list: oat milk, limes, basil.
MenubarMenubarMenuMenubarContentMenubarTrigger- +2 more
Notes app
View toggles the sidebar, the word count and the text size; File → Open recent switches notes. Everything else shows a toast.
Product ideas
Glass that behaves: blur the backdrop, never the words. Motion that shows where things came from, then gets out of the way when asked.
24 words
import { useState } from "react";
import { MenuCheckboxItem, MenuItem, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger } from "@/components/sheenui/menu/menu";
import { Menubar, MenubarContent, MenubarMenu, MenubarTrigger } from "@/components/sheenui/menubar/menubar";
// Package build (after the first npm release, or a packed tarball): import { Menubar, MenubarContent, MenubarMenu, MenubarTrigger, MenuCheckboxItem, MenuItem, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger } from "@sheenui/theme";
import { File as FileIcon, Printer as PrinterIcon } from "lucide-react";
export function Example() {
const [sidebar, setSidebar] = useState(true);
const [size, setSize] = useState("md");
return (
<Menubar aria-label="Application menu">
<MenubarMenu>
<MenubarTrigger>File</MenubarTrigger>
<MenubarContent>
<MenuItem icon={<FileIcon />} shortcut="mod+n">New note</MenuItem>
<MenuSub>
<MenuSubTrigger inset>Open recent</MenuSubTrigger>
<MenuSubContent>
<MenuItem>Meeting notes</MenuItem>
<MenuItem>Shopping list</MenuItem>
</MenuSubContent>
</MenuSub>
<MenuSeparator />
<MenuItem icon={<PrinterIcon />} shortcut="mod+p">Print…</MenuItem>
</MenubarContent>
</MenubarMenu>
<MenubarMenu>
<MenubarTrigger>View</MenubarTrigger>
<MenubarContent>
<MenuCheckboxItem checked={sidebar} onCheckedChange={setSidebar} shortcut="mod+\">
Sidebar
</MenuCheckboxItem>
<MenuSeparator />
<MenuRadioGroup value={size} onValueChange={setSize}>
<MenuLabel>Text size</MenuLabel>
<MenuRadioItem value="sm" shortcut="mod+-">Small</MenuRadioItem>
<MenuRadioItem value="md" shortcut="mod+0">Medium</MenuRadioItem>
</MenuRadioGroup>
</MenubarContent>
</MenubarMenu>
</Menubar>
);
}Files to copy
9 folders · 10 files · 4 packages
- From
theme/src/ components/menu/components/menubar/components/drawer/parts/sheet.tsxcomponents/kbd/components/status-icons/hooks/{use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, form.ts, glide-highlight.tsx, popup-a11y.ts, popup-motion.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/menubar.jsonRegistry item: menubar. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Edit and Help menus
Shortcut hints, a disabled item and a link item. The hints are display only: wire the handlers yourself.
import { MenuItem, MenuLinkItem, MenuSeparator } from "@/components/sheenui/menu/menu";
import { Menubar, MenubarContent, MenubarMenu, MenubarTrigger } from "@/components/sheenui/menubar/menubar";
// Package build (after the first npm release, or a packed tarball): import { Menubar, MenubarContent, MenubarMenu, MenubarTrigger, MenuItem, MenuLinkItem, MenuSeparator } from "@sheenui/theme";
export function Example() {
return (
<Menubar aria-label="Editor">
<MenubarMenu>
<MenubarTrigger>Edit</MenubarTrigger>
<MenubarContent>
<MenuItem shortcut="mod+z">Undo</MenuItem>
<MenuItem shortcut="shift+mod+z" disabled>Redo</MenuItem>
<MenuSeparator />
<MenuItem shortcut="mod+x">Cut</MenuItem>
<MenuItem shortcut="mod+c">Copy</MenuItem>
<MenuItem shortcut="mod+v">Paste</MenuItem>
</MenubarContent>
</MenubarMenu>
<MenubarMenu>
<MenubarTrigger>Help</MenubarTrigger>
<MenubarContent>
<MenuLinkItem href="#documentation">Documentation</MenuLinkItem>
<MenuItem>Keyboard shortcuts</MenuItem>
</MenubarContent>
</MenubarMenu>
</Menubar>
);
}API
Menubar
MenubarMenu · MenubarTrigger · MenubarContent
Keyboard
Accessibility
- role="menubar" with menu triggers (aria-haspopup, aria-expanded); name it with aria-label.
- Items are 44 px tall on touch screens, and the bar scrolls sideways instead of wrapping on narrow screens.
- Shortcut hints are shown as keys and exposed through aria-keyshortcuts.
When to use Menubar
- Use it as a desktop-style app menu bar for a web-based editor or admin tool with File, Edit and View menus along the top, where many commands are grouped the way a desktop application groups them.
- Use it when hovering a neighboring trigger should switch the open menu, as in desktop apps, and the accent tint should glide from one trigger to the next.
- Use it on narrow screens, where the bar scrolls sideways instead of wrapping to a second row, and set orientation="vertical" when you want the triggers stacked in a column.
- Skip it when you have one menu behind one button; Dropdown menu is simpler, and a site's top-level links with panels of content belong in a navigation menu instead.
- Pair it with MenuItem, MenuCheckboxItem and MenuSub for the contents, KbdShortcut for shown key combinations, and CommandPalette so rarely used commands are searchable too.
Frequently asked questions
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .