GitHub

Menubar

A visually persistent menu common in desktop applications that provides quick access to commands.

CMSPayload CMS Integration

Menubar structure can be managed through CMS fields for admin interfaces and application dashboards with customizable menu items.

Basic Usage

Loading...
MenubarA desktop-style application menu

Installation

pnpm add @corew500/ui

Usage

import {
  Menubar,
  MenubarMenu,
  MenubarTrigger,
  MenubarContent,
  MenubarItem,
  MenubarSeparator,
  MenubarShortcut,
} from "@mordecai-design-system/ui"
<Menubar>
  <MenubarMenu>
    <MenubarTrigger>File</MenubarTrigger>
    <MenubarContent>
      <MenubarItem>
        New Tab <MenubarShortcut>⌘T</MenubarShortcut>
      </MenubarItem>
      <MenubarItem>New Window</MenubarItem>
      <MenubarSeparator />
      <MenubarItem>Share</MenubarItem>
      <MenubarSeparator />
      <MenubarItem>Print</MenubarItem>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

Examples

With Submenus

<Menubar>
  <MenubarMenu>
    <MenubarTrigger>Edit</MenubarTrigger>
    <MenubarContent>
      <MenubarItem>Undo</MenubarItem>
      <MenubarItem>Redo</MenubarItem>
      <MenubarSeparator />
      <MenubarSub>
        <MenubarSubTrigger>Find</MenubarSubTrigger>
        <MenubarSubContent>
          <MenubarItem>Search the web...</MenubarItem>
          <MenubarSeparator />
          <MenubarItem>Find...</MenubarItem>
          <MenubarItem>Find Next</MenubarItem>
        </MenubarSubContent>
      </MenubarSub>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

With Checkbox Items

<Menubar>
  <MenubarMenu>
    <MenubarTrigger>View</MenubarTrigger>
    <MenubarContent>
      <MenubarCheckboxItem checked>
        Show Toolbar
      </MenubarCheckboxItem>
      <MenubarCheckboxItem>
        Show Sidebar
      </MenubarCheckboxItem>
      <MenubarSeparator />
      <MenubarItem>Full Screen</MenubarItem>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

With Radio Items

<Menubar>
  <MenubarMenu>
    <MenubarTrigger>View</MenubarTrigger>
    <MenubarContent>
      <MenubarLabel>Panel Position</MenubarLabel>
      <MenubarRadioGroup value="bottom">
        <MenubarRadioItem value="top">Top</MenubarRadioItem>
        <MenubarRadioItem value="bottom">Bottom</MenubarRadioItem>
        <MenubarRadioItem value="right">Right</MenubarRadioItem>
      </MenubarRadioGroup>
    </MenubarContent>
  </MenubarMenu>
</Menubar>

Sub-components

| Component | Description | |-----------|-------------| | Menubar | Root container | | MenubarMenu | Individual menu dropdown | | MenubarTrigger | Button that opens the menu | | MenubarContent | Dropdown content container | | MenubarItem | Clickable menu item | | MenubarSeparator | Visual divider | | MenubarLabel | Non-interactive label | | MenubarShortcut | Keyboard shortcut display | | MenubarGroup | Group of related items | | MenubarSub | Submenu container | | MenubarSubTrigger | Submenu trigger | | MenubarSubContent | Submenu content | | MenubarCheckboxItem | Toggleable checkbox item | | MenubarRadioGroup | Radio button group | | MenubarRadioItem | Radio button item |

Props

Menubar

PropTypeDefaultDescription
modalenumtrueWhether the menubar is modal.
disabledenumfalseWhether the whole menubar is disabled.
orientationenum'horizontal'The orientation of the menubar.
loopFocusenumtrueWhether to loop keyboard focus back to the first item when the end of the list is reached while using the arrow keys.
styleenumStyle applied to the element, or a function that returns a style object based on the component’s state.
classNameenumCSS class applied to the element, or a function that returns a class based on the component’s state.
renderenumAllows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.

MenubarCheckboxItem

PropTypeDefaultDescription
checkedenumWhether the checkbox item is currently ticked. To render an uncontrolled checkbox item, use the `defaultChecked` prop instead.
defaultCheckedenumfalseWhether the checkbox item is initially ticked. To render a controlled checkbox item, use the `checked` prop instead.
onCheckedChange(checked: boolean, eventDetails: MenuRootChangeEventDetails) => voidEvent handler called when the checkbox item is ticked or unticked.
onClickMouseEventHandler<HTMLElement>The click handler for the menu item.
disabledenumfalseWhether the component should ignore user interaction.
labelstringOverrides the text label to use when the item is matched during keyboard text navigation.
idstring@ignore
closeOnClickenumfalseWhether to close the menu when the item is clicked.
nativeButtonenumtrueWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (e.g. `<div>`).
styleenumStyle applied to the element, or a function that returns a style object based on the component’s state.
classNameenumCSS class applied to the element, or a function that returns a class based on the component’s state.
renderenumAllows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.

MenubarRadioItem

PropTypeDefaultDescription
value*anyValue of the radio item. This is the value that will be set in the MenuRadioGroup when the item is selected.
onClickMouseEventHandler<HTMLElement>The click handler for the menu item.
disabledenumfalseWhether the component should ignore user interaction.
labelstringOverrides the text label to use when the item is matched during keyboard text navigation.
idstring@ignore
closeOnClickenumfalseWhether to close the menu when the item is clicked.
nativeButtonenumtrueWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (e.g. `<div>`).
styleenumStyle applied to the element, or a function that returns a style object based on the component’s state.
classNameenumCSS class applied to the element, or a function that returns a class based on the component’s state.
renderenumAllows you to replace the component’s HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render.