navigation
Menu
A list of actions in a dropdown, enhanced with keyboard navigation. Built with Base UI and Tailwind CSS. Copy-paste ready.
Installation
Usage
Anatomy
Good to know
- Built on Base UI, not Radix. Handle item actions with
onClick. There is noonSelect. - The
DropdownMenu*names are aliases (DropdownMenuContentisMenuPopup,DropdownMenuLabelisMenuGroupLabel). Prefer theMenu*names. MenuTriggeris unstyled. Style it withrender={<Button variant="outline" />}. There is noasChild.- Clicking a
MenuItemcloses the menu. Checkbox and radio items keep it open. Change this per item withcloseOnClick. MenuGroupLabelmust be inside aMenuGrouporMenuRadioGroup; otherwise it throws an error.- Every
MenuRadioItemneeds avalue. The selection lives onMenuRadioGroup(value,defaultValue,onValueChange). - For links, use
renderon the item:<MenuItem render={<Link href="/settings" />}>Settings</MenuItem>. variant="destructive"styles an item in red.insetindents an item without an icon so it lines up with items that have one.MenuCheckboxItem variant="switch"shows a switch instead of a check mark.
API Reference
Menu
Root provider. Also exported as DropdownMenu.
MenuTrigger
Button that opens the menu. Also exported as DropdownMenuTrigger.
MenuPopup
The floating menu panel. Also exported as DropdownMenuContent.
MenuGroup
Groups related menu items. Also exported as DropdownMenuGroup.
MenuGroupLabel
Label displayed above a MenuGroup. Also exported as DropdownMenuLabel.
MenuItem
Standard action item. Also exported as DropdownMenuItem.
MenuCheckboxItem
Toggleable item with a checkmark indicator. Also exported as DropdownMenuCheckboxItem.
MenuRadioGroup / MenuRadioItem
Single-selection group. Also exported as DropdownMenuRadioGroup / DropdownMenuRadioItem.
MenuSeparator
Horizontal divider between item groups. Also exported as DropdownMenuSeparator.
MenuShortcut
Right-aligned keyboard hint <kbd> element. Also exported as DropdownMenuShortcut.
MenuSub / MenuSubTrigger / MenuSubPopup
Nested submenu. Also exported as DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent.
Examples
Open on Hover
The menu popup opens when the trigger is hovered rather than clicked, useful for navigation bars and toolbars.
With Checkbox
Uses MenuCheckboxItem to let users toggle individual options on or off within a persistent menu.
With Switch
MenuCheckboxItem supports a variant="switch" prop that displays a decorative switch indicator instead of a checkmark. Groups notification channels and activity types, each independently toggled via a switch.
With Radio Group
Uses MenuRadioGroup and MenuRadioItem to enforce single selection among a set of mutually exclusive options.
With Link
Renders MenuItem elements as anchor tags for navigating to routes directly from the menu popup.
With Group Label
Organizes menu items into labeled sections using MenuGroup and MenuGroupLabel for better scanability.
Nested Menu
Opens a MenuSub popup from a parent item to reveal a secondary list of options without closing the parent menu.
Close on Click
Demonstrates controlling closeOnClick behavior so the menu dismisses immediately when an item is selected.
Open a Dialog
Triggers a Dialog from a MenuItem, allowing secondary confirmation flows to be launched directly from a menu.
Account Menu
A circular avatar trigger with user info in the MenuGroupLabel header, account links, and a destructive "Sign out" item at the bottom.
File Actions
A labeled "File actions" trigger grouping rename, duplicate, move, and download items with keyboard shortcuts, plus a destructive delete at the bottom.
Icon Button Trigger
A compact size="icon" ghost button (⋮) as the trigger — a common pattern for per-row action menus in lists and tables.
Notification Settings
A bell icon trigger that opens a menu mixing variant="switch" channel toggles with standard checkbox activity options in separate groups.
Share with Export Sub-menu
A "Share" button trigger offering a copy link item alongside an "Export as" MenuSub with format choices (PDF, PNG, SVG, CSV).