Overlays
DropdownMenu
A menu of actions for one object, opening from a button; 250ms in from 97%, 150ms out to 99%.
Guidelines#
Use it for row and page overflow actions ("…"), account menus and bulk actions. Navigation belongs in the sidebar or tabs; a choice of value belongs in a Select.
What you provide: a DropdownMenuTrigger (a ghost icon-sm Button with MoreHorizontal for overflow), DropdownMenuContent with DropdownMenuItems (16px icon first, DropdownMenuShortcut last), DropdownMenuLabel, DropdownMenuSeparator, checkbox and radio items, and sub-menus. Put the destructive item last with variant="destructive", after a separator.
Items are 14px on accent when focused; inset aligns items without icons with those that have one.
Facts#
| Group | Overlays |
|---|---|
| Product | Max |
| Global | window.DigitalCrew.DropdownMenu |
| Source | max-agent: src/components/ui/dropdown-menu.tsx |
| Import in the app | import { DropdownMenu } from "@/components/ui/dropdown-menu"; |
API#
TypeScript declarations emitted from src/components/ui/dropdown-menu.tsx (the module also exports its other parts).
declare function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>): any;
declare function DropdownMenuPortal({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>): any;
declare function DropdownMenuTrigger({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>): any;
declare function DropdownMenuContent({ className, sideOffset, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Content>): any;
declare function DropdownMenuGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Group>): any;
declare function DropdownMenuItem({ className, inset, variant, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
inset?: boolean;
variant?: "default" | "destructive";
}): any;
declare function DropdownMenuCheckboxItem({ className, children, checked, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>): any;
declare function DropdownMenuRadioGroup({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>): any;
declare function DropdownMenuRadioItem({ className, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>): any;
declare function DropdownMenuLabel({ className, inset, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
inset?: boolean;
}): any;
declare function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>): any;
declare function DropdownMenuShortcut({ className, ...props }: React.ComponentProps<"span">): any;
declare function DropdownMenuSub({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>): any;
declare function DropdownMenuSubTrigger({ className, inset, children, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
inset?: boolean;
}): any;
declare function DropdownMenuSubContent({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>): any;
export { DropdownMenu, DropdownMenuPortal, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, };Example#
The code of the preview above: plain React.createElement against window.DigitalCrew, with realistic data.
<div id="root" class="p-6"></div>
<script>
(function () {
var h = React.createElement, DC = window.DigitalCrew, I = DC.Icons;
function App() {
return h("div", { className: "flex justify-center pt-2" },
h(DC.DropdownMenu, { defaultOpen: true, modal: false },
h(DC.DropdownMenuTrigger, { asChild: true }, h(DC.Button, { variant: "outline" }, "Actions", h(I.ChevronRight, { className: "rotate-90" }))),
h(DC.DropdownMenuContent, { className: "w-56", align: "center" },
h(DC.DropdownMenuLabel, null, "Campaign"),
h(DC.DropdownMenuGroup, null,
h(DC.DropdownMenuItem, null, h(I.Pencil), "Edit steps", h(DC.DropdownMenuShortcut, null, "E")),
h(DC.DropdownMenuItem, null, h(I.Copy), "Duplicate", h(DC.DropdownMenuShortcut, null, "⌘D")),
h(DC.DropdownMenuCheckboxItem, { checked: true }, "Stop on reply")),
h(DC.DropdownMenuSeparator, null),
h(DC.DropdownMenuItem, { variant: "destructive" }, h(I.Trash2), "Delete campaign"))));
}
ReactDOM.createRoot(document.getElementById("root")).render(h(DC.TooltipProvider, { delayDuration: 80 }, h(App)));
})();
</script>