Dropdown Menu

A list of actions opened from a button. Built on ui-sdk's Menu: arrow keys move, typing jumps to a row, Escape closes and focus returns to the trigger. Rows show keyboard focus with the hover highlight, never a ring, and ticks sit on the right.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Props

children
destructive
disabled

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoUse it for the actions on one record, opened from a button, like Edit, Duplicate and Delete behind an opportunity's ⋯ button.
DoOpen it from an IconButton passed to DropdownMenuTrigger's render, with an aria-label that names the record, like Opportunity actions. In a table, each row's trigger needs its own name.
DoPut Delete, Remove or Archive last, below a DropdownMenuSeparator, and set destructive on it. The label says what it does, so the red tone is never the only signal.
DoUse DropdownMenuCheckboxItem and DropdownMenuRadioItem for rows that toggle or choose. Their tick sits on the right, so every label starts at the same edge.
Don'tGive a row a focus ring, a coloured fill or a radius as large as the menu's. Rows show focus with the hover highlight, a chosen row shows a tick, and a row's corners stay smaller than the menu's.
Don'tUse it to choose a value for a form field, like a matter type, or add a search field to it. Use Select, or a Popover with PopoutSearch for a list that needs searching.

Props

DropdownMenu also takes ui-sdk's Menu options (open, defaultOpen, onOpenChange, onAction, controller). Items take value, label, closeOnSelect and onSelect; returning a Promise from onSelect keeps the row busy and the menu open until it settles.

DropdownMenu

No props of its own.

DropdownMenuContent

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
classNamestring—Classes added to the root element, merged with its own. Tokens only.
sideOffsetunknown4The gap between it and what it opens from, in pixels.

DropdownMenuItem

PropTypeDefaultDescription
childrenReactNode—An icon first, then the label: `<Trash2 /> Delete`.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

DropdownMenuCheckboxItem

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

DropdownMenuRadioItem

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

DropdownMenuLabel

PropTypeDefaultDescription
classNamestring—Classes added to the root element, merged with its own. Tokens only.

DropdownMenuSeparator

PropTypeDefaultDescription
classNamestring—Classes added to the root element, merged with its own. Tokens only.

DropdownMenuSubTrigger

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

import {
  Button,
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuTrigger,
} from "@leap-crm/design-system";

<DropdownMenu>
  <DropdownMenuTrigger render={<Button intent="outline">Open menu</Button>} />
  <DropdownMenuContent>
    <DropdownMenuItem>Edit details</DropdownMenuItem>
    <DropdownMenuItem>Duplicate</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Actions

Icon and label rows, shortcuts as keys on the right, a submenu with a grey chevron, a disabled row in muted text, and Delete in the danger tone below a divider.

Checkbox and radio rows

Rows that toggle or choose show a navy tick on the right, with no fill; the highlight stays grey for hover and keyboard. Labels name each group.

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { Archive, Copy, MoreHorizontal, Pencil, Share2, Trash2 } from "lucide-react";

import { Button, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, IconButton } from "@leap-crm/design-system";

function RowActions() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger
        render={
          <IconButton
            intent="outline"
            icon={<MoreHorizontal />}
            aria-label="Opportunity actions"
          />
        }
      />
      <DropdownMenuContent className="w-56">
        <DropdownMenuItem shortcut="mod+e">
          <Pencil /> Edit details
        </DropdownMenuItem>
        <DropdownMenuItem shortcut="mod+d">
          <Copy /> Duplicate
        </DropdownMenuItem>
        <DropdownMenuSub>
          <DropdownMenuSubTrigger>
            <Share2 /> Share
          </DropdownMenuSubTrigger>
          <DropdownMenuSubContent className="w-44">
            <DropdownMenuItem>Copy link</DropdownMenuItem>
            <DropdownMenuItem>Email a colleague</DropdownMenuItem>
          </DropdownMenuSubContent>
        </DropdownMenuSub>
        <DropdownMenuItem disabled>
          <Archive /> Archive
        </DropdownMenuItem>
        <DropdownMenuSeparator />
        <DropdownMenuItem destructive>
          <Trash2 /> Delete
        </DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  );
}

Keyboard

The keys it answers to. Tab moves between components, arrows move within them.

KeysWhat they do
EnterSpaceArrowDownOpen the menu and focus the first item.
ArrowUpOpens the menu and focuses the last item.
ArrowDownArrowUpMove between items, skipping separators and labels.
HomeEndMove to the first and last items.
TypingMoves to the next item that starts with what was typed.
EnterRuns the focused item, closes the menu and returns focus.
ArrowRightArrowLeftOpen a submenu, and close it back to its trigger.
EscapeCloses the menu and returns focus to the trigger.
TabCloses the menu.