Overlays

Dropdown menu

A list of actions or options from a button. Items, checkboxes, radios, labels and submenus, on a blurred dark popup.

packages/design-system/components/ui/dropdown-menu.tsx

Examples

Actions, with a destructive item. Click to open
Checkbox and radio items

Anatomy

  1. 01Trigger
  2. 02Popup, min-w-48, dark and blurred
  3. 03Groups with labels
  4. 04Items with icons and shortcuts
  5. 05Separators

Usage

import {
  DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger,
} from "@repo/design-system/components/ui/dropdown-menu";

<DropdownMenu>
  <DropdownMenuTrigger render={<Button variant="outline" />}>Project</DropdownMenuTrigger>
  <DropdownMenuContent>
    <DropdownMenuItem onClick={invite}>Invite client</DropdownMenuItem>
    <DropdownMenuSeparator />
    <DropdownMenuItem variant="destructive" onClick={archive}>Archive</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Props

PropTypeDefaultDescription
open / defaultOpenbooleannoneControlled or uncontrolled open state, on the root.
onOpenChange(open: boolean, details) => voidnoneCalled when the popup opens or closes.
DropdownMenuTrigger renderReactElement | (props, state) => ReactElementnoneBase UI's replacement for asChild: render the part as another element, such as a Button or a Link.
DropdownMenuItem variant"default" | "destructive""default"Destructive colours the item and its icon red.
insetbooleannoneOn items and labels: indent to line up with items that have an icon or check.
DropdownMenuLabelGroupLabelnoneMust sit inside a DropdownMenuGroup.
side"top" | "bottom" | "left" | "right" | "inline-start" | "inline-end"noneWhich side of the trigger the popup opens on.
align"start" | "center" | "end""start"How the popup lines up with the trigger along that side.
sideOffsetnumber4The gap between trigger and popup, in pixels.
classNamestringnoneMerged last with cn(). Use it for layout (width, margin), not to restyle the component.

Guidance

Do

  • Group related items and label the groups.
  • Put destructive items last, after a separator.

Don't

  • Use it for navigation between pages.