Skip to the page
Supply UI

Menu item

In code: MenuItem

A part of Menu: use it inside one.

One action in a menu. shortcut shows its key as a hint; your code handles the key itself.

Preview

Use

The code of the preview above
import { Button, Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '@/components/ui';
import { ChevronDown, Copy, Pencil, Trash2 } from 'lucide-react';

function MenuDemo() {
  return (
    <Menu>
      <MenuTrigger render={<Button />}>Booking<ChevronDown /></MenuTrigger>
      <MenuContent>
        <MenuItem><Pencil />Edit</MenuItem>
        <MenuItem><Copy />Duplicate</MenuItem>
        <MenuSeparator />
        <MenuItem danger><Trash2 />Cancel booking</MenuItem>
      </MenuContent>
    </Menu>
  );
}

This page as text, for an AI

Options

OptionTypeWhat it does
className stringMore classes on the outer element, for layout around it (margins, grid placement), not to restyle it.
danger booleanIn the danger colour, for an action that deletes or cannot be undone.

It also takes the 283 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.

Without React

With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:

components/button.csscomponents/popups.csscomponents/icons.csscomponents/menu-items-tick.csscomponents/prose.cssparts/listbox.cssparts/menubar.css

In the examples

Small screens made with it and the rest of the kit. They work: click, type and choose in them.

Right-click a product, or press and hold
  • Linen tote
  • Enamel mug
  • Wall calendarFeatured
  • Sticker sheet
More on right-click The actions of a row, where the hand already is
Grid on100%
File, View, the old way Menus of an application, ticks and choices included

On top of the page: states, do and don’t

States. Closed, opening (fades and rises), open, closing (fades before what it changed appears: afterClose). While open, focus is inside and Escape closes it; when it closes, focus goes back to what opened it.

Do

  • Name every dialog, drawer and popover (DialogTitle, DrawerTitle, or aria-label).
  • Use AlertDialog for anything that cannot be undone, with the action named on its button ("Delete 3 files").
  • Use a Drawer on a phone for what a Popover does on a computer.

Don't

  • Don't open a dialog from a dialog; change what the open one shows instead.
  • Don't put the only way to do something in a right-click menu or a tooltip.
  • Don't use a toast for something the person must not miss: that is an Alert on the page.