Rendering a visually persistent menu similar to those found near the top of the window in desktop applications. This example is based on the WAI-ARIA Menu Bar Pattern.

import { Menu, MenuBar, MenuItem, MenuSeparator } from "./menu";
import "./style.css";

export default function Example() {
  return (
      <Menu label="File">
        <MenuItem label="New Tab" />
        <MenuItem label="New Window" />
        <MenuItem label="Open File" />
        <MenuItem label="Open Location" />
        <MenuSeparator />
        <MenuItem label="Close Window" />
        <MenuItem label="Close Tab" />
        <MenuItem label="Save Page As" />
        <MenuSeparator />
        <Menu label="Share">
          <MenuItem label="Email Link" />
          <MenuItem label="Messages" />
          <MenuItem label="Notes" />
          <MenuItem label="Reminders" />
          <MenuItem label="More..." />
        <MenuSeparator />
        <MenuItem label="Print" />
      <Menu label="Edit">
        <MenuItem label="Undo" />
        <MenuItem label="Redo" />
        <MenuSeparator />
        <MenuItem label="Cut" />
        <MenuItem label="Copy" />
        <MenuItem label="Paste" />
        <MenuItem label="Paste and Match Style" />
        <MenuItem label="Delete" />
        <MenuItem label="Select All" />
        <MenuSeparator />
        <Menu label="Find">
          <MenuItem label="Search the Web" />
          <MenuSeparator />
          <MenuItem label="Find" />
          <MenuItem label="Find Next" />
          <MenuItem label="Find Previous" />
          <MenuItem label="Use Selection for Find" />
          <MenuItem disabled label="Jump to Selection" />
        <Menu label="Spelling and Grammar">
          <MenuItem label="Show Spelling and Grammar" />
          <MenuItem label="Check Document Now" />
        <Menu label="Substitutions">
          <MenuItem label="Show Substitutions" />
        <MenuSeparator />
        <MenuItem disabled label="Start Dictation" />
        <MenuItem label="Emoji &amp; Symbols" />
      <Menu label="View">
        <MenuItem disabled label="Stop" />
        <MenuItem label="Force Reload This Page" />
        <MenuSeparator />
        <MenuItem label="Enter Full Screen" />
        <MenuItem disabled label="Actual Size" />
        <MenuItem label="Zoom In" />
        <MenuItem label="Zoom Out" />
        <MenuSeparator />
        <MenuItem label="Cast" />
        <MenuSeparator />
        <Menu label="Developer">
          <MenuItem label="View Source" />
          <MenuItem label="Developer Tools" />
          <MenuItem label="Inspect Elements" />
          <MenuItem label="JavaScript Console" />
          <MenuItem label="Allow JavaScript from Apple Events" />

Can I use MenuBar for site navigation?

Short answer: Yes, but you probably shouldn't.

ARIA doesn't specify how you should structure the contents of your site. It just describes how the roles should behave. If you've designed your site navigation to work precisely like a menu bar and it's clear to the user (e.g., your app looks like a desktop application), then you can use MenuBar.

Using ARIA roles is like signing a contract with the user. You're saying, "I'm going to use this role to represent this thing, and you can expect it to work like this". If you don't follow through, you're breaking that contract, and the user will be confused.

In the case of the menubar role, the user expects the whole component to work as a single tab stop. The Tab key will focus on the first item in the menu bar. Pressing Tab again will focus on the next tabbable element outside the menu bar. Inside the menu bar, the user expects to be able to use the arrow keys to navigate between menu items. Ariakit provides this behavior out of the box.