Dropdown menu on Radix: the menu grows out of its button, items cascade, a pill highlight stretches between items, submenus grow from their item.
Click meTap me
Orders
No changes yet
Order
Status
Date
Amount
Actions
Order #1042
Paid
Oct 2
€320.00
Order #1043
Pending
Oct 3
€86.40
Order #1044
Paid · Priority
Oct 3
€1,210.00
Order #1045
Shipped
Oct 4
€54.90
Order #1046
Pending
Oct 5
€412.00
5 ordersTotal €2,083.30
dropdown-menu · , lively
dropdown-menu-demo.tsx
When to use
Use it for the actions on one thing: a row, a header button or a file. It holds plain actions with shortcuts, checkbox and radio items, submenus, a destructive item and loading, empty or error rows for async groups.
When not to use
To pick a value for a form field use Combobox. For a long action list that needs a filter use Command Palette; for several menus side by side use Menubar.
Use it for the actions on one thing: a table row's "⋯" button, an account button in a header, a toolbar's "Columns" picker, the right-click menu of a file. It holds plain actions with shortcuts, checkbox and radio items, submenus and a destructive group. To pick one value for a form field, use the combobox; when the list is long enough to need a filter, use the command palette's verbs preset.
The motion follows the three beats. Pressing the trigger charges it: a button sinks, an icon button stretches toward the menu. The button's surface then acts: a copy of it grows into the menu panel, opaque from its first frame and never bouncing, while the button stays where it is. The menu settles as its items cascade in from the button's side. A pill sits under the highlighted item and follows the pointer and the arrow keys as one body, stretching across a label or a separator. Checkbox items draw their check; radio items share one ball that travels to the chosen row. A submenu grows out of its row to the side with room; on a narrow screen with room on neither side it slides over its parent panel and stays inside the viewport (and collisionBoundary). Choosing an item sinks it, then the menu contracts back into the button. With the context preset there is no button: a small ball at the pointer grows into the panel. calm shortens and quiets all of this, playful moves more.
The parts mirror Radix DropdownMenu and shadcn's flat names, so existing shadcn code keeps working; the same parts are also on the namespace (DropdownMenu.Item, DropdownMenu.Sub, …). Give the trigger your own button with asChild: the morph starts from its real corners. open, a checkbox item's checked, a radio group's value and a submenu's open are each controlled or uncontrolled (defaultOpen, defaultChecked, defaultValue). An item's onSelect runs at once; the menu closes after the row's short sink, and event.preventDefault() keeps it open as in Radix. A menu with no items should not open: disable its trigger instead. For async groups use DropdownMenuLoading, DropdownMenuEmpty and DropdownMenuError (with onRetry).
Pick a layout with preset (menu, context, actions) and a density with size (sm, md). The motion is the same in every preset. Set the character app-wide with MotionKitProvider, or per menu with temperament.
The menu preset from a text button: checkbox rows draw and erase their check, and onSelect with preventDefault() keeps the menu open while columns are toggled.
The context preset is a Radix ContextMenu: right-click (or long-press on touch, or the ContextMenu key) on a tile and the menu grows from the pointer's point; "Move to" grows its submenu out of the row.
Built on Radix DropdownMenu and ContextMenu: the trigger is a button with aria-haspopup="menu", aria-expanded and aria-controls; the panel is a menu labelled by its trigger; items are menuitem, menuitemcheckbox and menuitemradio with aria-checked. Disabled items are skipped by the arrow keys and typeahead.
Focus goes to the first item when the menu is opened from the keyboard and returns to the trigger as soon as closing starts; the trigger's focus ring waits until the panel has landed back in it.
The highlight pill, the radio ball, the check, the slot rings and the flying copy of the trigger are aria-hidden. When the last input was the keyboard the pill carries a ring-tinted rim, so the highlighted row is visible at 3:1 against the panel.
Rows are 32 px tall (28 px at sm, 44 px on touch screens). Labels and shortcuts use muted-foreground on popover, destructive rows destructive on popover and on the destructive tint, AA in both themes.
A loading group marks the menu aria-busy; empty and error messages are not menu items (role="none").
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") nothing sinks, stretches or morphs: the trigger stays still and the panel fades in at its final place, the items fade in together, the pill glides between rows without stretching, the check fades in whole, the radio ball glides without squash, submenus fade in beside their row and closing fades the panel out in place. The open menu is the same picture as the morph's last frame, and every key works the same.
The open morph is one layout animation of the panel's surface (transform), its rows counter-scaled so text never stretches; the context ball and submenus grow by a rounded clip-path. Rows, the pill and the ball animate transform and opacity; the pill's height is the one layout property animated, on a single absolutely positioned element.
Nothing runs at rest and nothing loops. A menu's content mounts only while it is open, so a table with fifty row menus keeps one moving part at a time.
Third-party dependencies, measured apart: @radix-ui/react-dropdown-menu, @radix-ui/react-context-menu (for the context preset) and motion.
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-context-menu, @radix-ui/react-dropdown-menu, motion.
Dependencies
@radix-ui/react-context-menu · peer
@radix-ui/react-dropdown-menu · peer
motion · peer
Triggers
click, press, hover, pointer movement
Reduced motion
No sink, stretch or morph: the panel fades in at its final place, items fade in together, the pill glides without stretching, the check fades in whole, the radio ball glides without squash and closing fades the panel out in place.
Keyboard
Enter / Space / ArrowDown on the trigger
Opens the menu out of its button, focus on the first item
Shift+F10 / ContextMenu key (context preset)
Opens the context menu at the focused area
ArrowDown / ArrowUp
Next / previous enabled item; the pill glides, and stretches across a label or separator
Home / End
First / last item
Type a letter
Moves to the next item starting with it
Enter / Space
Selects the item (it sinks, then the menu contracts into its button); toggles a checkbox item, picks a radio item
ArrowRight (ArrowLeft in RTL)
Opens a submenu out of its row, focus on its first item
ArrowLeft (ArrowRight in RTL)
Closes the submenu, focus back on its row
Escape
Closes the open submenu only, focus back on its row; from the root list, closes the menu, focus back on the trigger
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)