3.0.0-alpha.4 Alpha
Light Dark Light Dark System Search /

Menu

<wa-menu> Since 2.0 stable

Menus provide a list of options for the user to choose from.

You can use menu items, menu labels, and dividers to compose a menu. Menus support keyboard interactions, including type-to-select an option.

Undo Redo Cut Copy Paste Delete
<wa-menu style="max-width: 200px;">
  <wa-menu-item value="undo">Undo</wa-menu-item>
  <wa-menu-item value="redo">Redo</wa-menu-item>
  <wa-divider></wa-divider>
  <wa-menu-item value="cut">Cut</wa-menu-item>
  <wa-menu-item value="copy">Copy</wa-menu-item>
  <wa-menu-item value="paste">Paste</wa-menu-item>
  <wa-menu-item value="delete">Delete</wa-menu-item>
</wa-menu>

Menus are intended for system menus (dropdown menus, select menus, context menus, etc.). They should not be mistaken for navigation menus which serve a different purpose and have a different semantic meaning. If you're building navigation, use <nav> and <a> elements instead.

Examples

In Dropdowns

Menus work really well when used inside dropdowns.

Edit Cut Copy Paste
<wa-dropdown>
  <wa-button slot="trigger" caret>Edit</wa-button>
  <wa-menu>
    <wa-menu-item value="cut">Cut</wa-menu-item>
    <wa-menu-item value="copy">Copy</wa-menu-item>
    <wa-menu-item value="paste">Paste</wa-menu-item>
  </wa-menu>
</wa-dropdown>

To create a submenu, nest an <wa-menu slot="submenu"> in any menu item.

Undo Redo Cut Copy Paste Find Find… Find Next Find Previous Transformations Make uppercase Make lowercase Capitalize
<wa-menu style="max-width: 200px;">
  <wa-menu-item value="undo">Undo</wa-menu-item>
  <wa-menu-item value="redo">Redo</wa-menu-item>
  <wa-divider></wa-divider>
  <wa-menu-item value="cut">Cut</wa-menu-item>
  <wa-menu-item value="copy">Copy</wa-menu-item>
  <wa-menu-item value="paste">Paste</wa-menu-item>
  <wa-divider></wa-divider>
  <wa-menu-item>
    Find
    <wa-menu slot="submenu">
      <wa-menu-item value="find">Find…</wa-menu-item>
      <wa-menu-item value="find-previous">Find Next</wa-menu-item>
      <wa-menu-item value="find-next">Find Previous</wa-menu-item>
    </wa-menu>
  </wa-menu-item>
  <wa-menu-item>
    Transformations
    <wa-menu slot="submenu">
      <wa-menu-item value="uppercase">Make uppercase</wa-menu-item>
      <wa-menu-item value="lowercase">Make lowercase</wa-menu-item>
      <wa-menu-item value="capitalize">Capitalize</wa-menu-item>
    </wa-menu>
  </wa-menu-item>
</wa-menu>

As a UX best practice, avoid using more than one level of submenus when possible.

Slots

Name Description
(default) The menu's content, including menu items, menu labels, and dividers.

Events

Name Description
wa-select Emitted when a menu item is selected.

Dependencies

This component automatically imports the following elements. Subdependencies, if any exist, will also be included in this list.

Importing

The autoloader is the recommended way to import components. If you prefer to do it manually, use one of the following code snippets.

CDN npm React

To manually import this component from the CDN, use the following code.

import 'https://early.webawesome.com/webawesome@3.0.0-alpha.4/dist/components/menu/menu.js';
Coming soon! Coming soon!
    No results