Mục lục tham khảo

Thành phần

Menubar

Menubar on Base UI Menubar and Menu: heavy top rule and bottom hairline, ink-fill trigger when open, Dropdown Menu rows.

Nội dung tham khảo viết bằng tiếng Anh; mục “Vietnamese” có ví dụ tiếng Việt.

Xem trước

Install

bash

npx shadcn add @eloquent/menubar

Usage

tsx

import {
  Menubar, MenubarContent, MenubarItem, MenubarMenu, MenubarSeparator, MenubarShortcut, MenubarTrigger,
} from "@/components/ui/menubar";

<Menubar aria-label="Editor">
  <MenubarMenu>
    <MenubarTrigger>File</MenubarTrigger>
    <MenubarContent>
      <MenubarItem>New story<MenubarShortcut>⌘N</MenubarShortcut></MenubarItem>
      <MenubarSeparator />
      <MenubarItem>Print</MenubarItem>
    </MenubarContent>
  </MenubarMenu>
  <MenubarMenu>
    <MenubarTrigger>Edit</MenubarTrigger>
    <MenubarContent>
      <MenubarItem>Undo</MenubarItem>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

Name the bar with aria-label. Rows, checkbox and radio items, labels (inside a MenubarGroup) and submenus work as in Dropdown Menu.

States

Disabled trigger
StateTreatment
BarHeavy 3px ink rule above, hairline below, no box
Trigger focus2px ink outline, 2px offset
Menu openTrigger takes the ink fill with paper text
RowsInk-fill highlight, ink check and dot, hairline separators
Disabled triggerhalftone text, cursor-not-allowed

Keyboard

KeyAction
TabEnter the bar (one stop)
ArrowLeft / ArrowRightMove between triggers
Enter / Space / ArrowDownOpen the focused trigger's menu with the first row highlighted
ArrowDown / ArrowUpMove the highlight in a menu
ArrowRightOn a plain row, open the next menu; on a submenu row, open the submenu
ArrowLeftClose a submenu and return to its row
EscClose; focus returns to the trigger

Vietnamese

Ink adaptation

Upstream shadcn's border box, shadow, radius and animation are removed. The bar is a heavy rule above and a hairline below; triggers are Barlow capitals at 44px high with no hover effect, and the open menu's trigger takes the ink fill. Rows follow Dropdown Menu. Built on Base UI Menubar and Menu.