Skip to main content

Common Examples

import { Menu } from "@servicetitan/anvil2";

function ExampleComponent() {
  return (
    <Menu label="Click me!">
      <Menu.Item label="Item 1" />
      <Menu.Item label="Item 2" />
      <Menu.Item label="Item 3" />
    </Menu>
  );
}

Creating simple dropdown menus

The Menu and Menu.Item components can be used to compose basic dropdown menus.

Nesting menus in dropdowns

To create nested dropdown menus, simply add a Menu as a child of another Menu.

Creating custom menu triggers

To use a custom trigger element, use the trigger prop of the Menu, and omit the label prop (and any other prop meant to be passed to the default Button trigger).

React Accessibility

When using a custom trigger, make sure that the trigger:
  • Can receive focus via keyboard when tabbing.
  • Opens the menu when the user presses enter.
  • Closes the menu and returns focus to the trigger when the user presses escape.
For more guidance on accessible menu interactions, see keyboard navigation and focus management best practices.
Last modified on January 23, 2026