Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
DropdownMenu ├── DropdownMenuTrigger └── DropdownMenuContent ├── DropdownMenuLabel (optional) ├── DropdownMenuGroup (optional) │ └── DropdownMenuItem | DropdownMenuCheckboxItem | DropdownMenuRadioItem │ ├── DropdownMenuItemText │ └── DropdownMenuShortcut (optional) ├── DropdownMenuRadioGroup (optional) ├── DropdownMenuSeparator (optional) └── DropdownMenuSub (optional) ├── DropdownMenuSubTrigger └── DropdownMenuSubContent
Examples
Checkboxes
Loading...
Default Example
Loading...
Default
Loading...
Radio
Loading...
Submenus
Loading...
User Profile
Loading...
With Icons
Loading...
With Shortcuts
Loading...
API Reference
DropdownMenu
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | — | Unique identifier used to connect the component parts. |
ids | ElementIds | undefined | — | Overrides generated identifiers for individual parts. |
defaultHighlightedValue | string | null | undefined | — | Configures default highlighted value. |
highlightedValue | string | null | undefined | — | Configures highlighted value. |
onHighlightChange | ((details: HighlightChangeDetails) => void) | undefined | — | Runs when highlight changes. |
onSelect | ((details: SelectionDetails) => void) | undefined | — | Runs when select changes. |
anchorPoint | Point | null | undefined | — | Configures anchor point. |
loopFocus | boolean | undefined | — | Configures loop focus. |
positioning | PositioningOptions | undefined | — | Configures floating-element placement and collision handling. |
closeOnSelect | boolean | undefined | true | Configures close on select. |
open | boolean | undefined | — | Whether the component is open when controlled. |
onOpenChange | ((details: OpenChangeDetails) => void) | undefined | — | Runs when open changes. |
defaultOpen | boolean | undefined | — | Initial open state when uncontrolled. |
typeahead | boolean | undefined | — | Configures typeahead. |
composite | boolean | undefined | — | Configures composite. |
navigate | ((details: NavigateDetails) => void) | null | undefined | — | Configures navigate. |
triggerValue | string | null | undefined | — | Configures trigger value. |
defaultTriggerValue | string | null | undefined | — | Configures default trigger value. |
onTriggerValueChange | ((details: TriggerValueChangeDetails) => void) | undefined | — | Runs when trigger value changes. |
Context, Hooks, and Types
| Export | API |
|---|---|
DropdownMenuContext | Render-prop component that exposes component state and actions. |
DropdownMenuRootProvider | Provides an externally created API to the component tree. |
useDropdownMenu | Creates or accesses the component API. |
useDropdownMenuContext | Returns the nearest component API. |
Angular
React
Solid
Svelte
Vue