1 ---
2 generate_toc: true
3 ---
4
5 import { ComponentExample } from "@/components/ComponentExample"
6 import { ComponentReference } from "@/components/ComponentReference"
7 import { getOsShortcut, Kbd } from "docs-ui"
8
9 export const osShortcut = getOsShortcut()
10
11 export const metadata = {
12 title: `Dropdown Menu`,
13 }
14
15 # {metadata.title}
16
17 A component for rendering dropdown menus that display a set of actions or options to users.
18
19 In this guide, you'll learn how to use the Dropdown Menu component.
20
21 <ComponentExample name="dropdown-menu-demo" />
22
23 ## Usage
24
25 ```tsx
26 import { DropdownMenu } from "@medusajs/ui"
27 ```
28
29 ```tsx
30 <DropdownMenu>
31 <DropdownMenu.Trigger>Trigger</DropdownMenu.Trigger>
32 <DropdownMenu.Content>
33 <DropdownMenu.Item>Edit</DropdownMenu.Item>
34 <DropdownMenu.Item>Add</DropdownMenu.Item>
35 <DropdownMenu.Item>Delete</DropdownMenu.Item>
36 </DropdownMenu.Content>
37 </DropdownMenu>
38 ```
39
40 ---
41
42 ## API Reference
43
44 <ComponentReference mainComponent="DropdownMenu" componentsToShow={[
45 "DropdownMenu",
46 "DropdownMenu.Trigger",
47 "DropdownMenu.Content",
48 "DropdownMenu.Item",
49 "DropdownMenu.Shortcut",
50 "DropdownMenu.Hint",
51 "DropdownMenu.RadioGroup",
52 "DropdownMenu.RadioItem"
53 ]} />
54
55 ---
56
57 ## Examples
58
59 ### Sorting
60
61 This example shows how to display collection sorting choices using a Dropdown Menu.
62
63 <ComponentExample name="dropdown-menu-sorting" />
64
65 ### Dropdown with Submenu
66
67 <ComponentExample name="dropdown-menu-submenu" />
68
69 ### Disabled Items and Using Icons
70
71 <ComponentExample name="dropdown-menu-disabled-icons" />
72
73 ### Keyboard Shortcuts (with handling)
74
75 This example shows how to visually display keyboard shortcuts in the menu and handle them in your application logic.
76
77 You can use the <Kbd>{osShortcut}E</Kbd> and <Kbd>{osShortcut}D</Kbd> shortcuts to trigger the actions of the dropdown items.
78
79 <ComponentExample name="dropdown-menu-shortcuts" hideFeedback />