Skip to content

React Dropdown Menu

A glass React dropdown menu with icons, shortcuts, groups, checkbox and radio items and submenus, whose highlight glides from item to item.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/menu.json

Account

Signed in as Ada.

  • Menu
  • MenuSub
  • MenuItem
  • MenuGroup
  • MenuLabel
  • +14 more
  • +11 more

Account menu

Icons, shortcut hints (⌘ on a Mac, Ctrl elsewhere), a badge, a submenu, a disabled item and a destructive one. Open it with Enter, Space or ↓, then move with the arrow keys; → opens the submenu.

Files to copy

8 folders · 10 files · 4 packages
From theme/src/
  • components/menu/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/status-icons/
  • hooks/{use-latest.ts, use-media-query.ts, use-preferences.ts}
  • motion/tokens.ts
  • lib/{cn.ts, form.ts, glide-highlight.tsx, popup-a11y.ts, popup-motion.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/menu.jsonRegistry item: menu. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/avatar/
  • components/badge/
  • components/button/
  • components/description-list/copy-button.tsx
  • components/spinner/
  • hooks/use-magnetic.ts
  • motion/gate.ts
  • lib/{initials.ts, state-light.tsx, warn-once.ts}
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/avatar.json https://lokendra-builds.github.io/sheenui/r/badge.json https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/description-list.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Checkbox and radio items

Toggles and a single choice that keep the menu open, so several can be changed in one go. The preview below follows along.

toolbar, minimap shown · comfortable

Row actions

An icon button per row with the menu aligned to its end. "Open on GitHub" is a real link (MenuLinkItem), so ⌘/Ctrl-click opens it in a new tab.

  • Q3 roadmap.pdf2.4 MB
  • Brand assets.zip48 MB
  • Onboarding notes.md12 KB

Bottom sheet on phones

mobile='sheet' opens the menu as a bottom sheet under 640px wide: full width, a drag handle you can swipe down, items scrolling inside a 85dvh cap, safe-area padding. The default, 'popup', keeps the anchored menu. Press “Preview on a phone” to try it on a desktop screen (or narrow the window).

API

PropTypeDefaultDescription
mobileMobilePresentation"popup"How the menu opens on a phone-width screen (max-width: 640px): "popup" is the usual menu next to the trigger; "sheet" is a bottom sheet with a drag handle, swipe-down to dismiss, scrolling items capped at 85 dvh and home-indicator padding. Escape closes and focus returns to the trigger in both.
open / defaultOpenbooleanfalseControlled or uncontrolled open state.
onOpenChange(open, details) => voidNoneCalled when the menu opens or closes; details.reason says why.
modalbooleantrueLock page scroll and outside clicks while open.
loopFocusbooleantrueArrow keys wrap from the last item to the first.
MenuTrigger renderReactElementNoneRender the trigger as your own element, e.g. render={<Button />}. openOnHover and delay are also supported.
Menu ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example highlightItemOnHover, onOpenChangeComplete, onItemHighlighted, orientation, disabled, closeParentOnEsc).
MenuTrigger ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example disabled, handle, payload, delay, closeDelay, openOnHover).
PropTypeDefaultDescription
side"top" | "bottom" | "left" | "right" | "inline-start" | "inline-end""bottom"Preferred side of the trigger; it flips when there is no room.
align"center" | "end" | "start""start"Sets the alignment along that side.
sideOffsetnumber6Gap between the trigger and the menu, in px (each part has its own default).
alignOffsetnumber0Shift along the alignment axis, in px (each part has its own default).
collisionPaddingnumber12Space kept from the viewport edges, in px.
matchTriggerWidthbooleanfalseMake the menu at least as wide as its trigger.
anchorElement | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | nullNoneElement to position against instead of the trigger.
positionerClassNamestringNoneClasses for the positioner (the fixed element around the popup).
labelsPartial<MenuLabels>defaultMenuLabelsSpoken text. Merged over defaultMenuLabels. Every other string, for translation: labels={{ submenu: "…" }}; omitted keys keep the English of defaultMenuLabels. All 2 keys of MenuLabels are listed in the key table under the props table.
PropTypeDefaultDescription
iconReactNodeNoneShows an icon before the label (decorative).
descriptionReactNodeNoneShows the second line under the label.
shortcutstring | readonly string[]NoneKeyboard shortcut to show, e.g. "mod+c" (⌘C on a Mac, Ctrl+C elsewhere). It is also set as aria-keyshortcuts. Showing it does not bind it: handle the key yourself.
shortcutLabelsPartial<KbdLabels>defaultKbdLabelsKey names for the shortcut (i18n). Every other string, for translation: shortcutLabels={{ mac: "…" }}; omitted keys keep the English of defaultKbdLabels. All 4 keys of KbdLabels are listed in the key table under the props table.
trailingReactNodeNoneAnything else at the end of the row (a badge, a count).
insetbooleanNoneLeave the icon slot empty so the label lines up with items that have icons.
tone"neutral" | "danger""neutral""danger" for destructive actions: red text and a red highlight.
disabled / closeOnClick / onClick / labelBase UI Menu.Item propsNonelabel overrides the text used for typeahead.

Inherited Base UI props

PropTypeDefaultDescription
MenuCheckboxItem: checked / defaultChecked / onCheckedChangeboolean / boolean / (checked: boolean) => voidNoneControlled or uncontrolled checked state (Base UI).
MenuRadioGroup: value / defaultValue / onValueChangestring / string / (value: string) => voidNoneThe chosen item of a radio group; give each MenuRadioItem its own value (Base UI).
MenuSubTrigger: openOnHover / delayboolean / numberNoneOpen the submenu on hover, after the delay in ms (Base UI).
PropTypeDefaultDescription
shortcutstring | readonly string[]NoneKeyboard shortcut to show, e.g. "mod+c" (⌘C on a Mac, Ctrl+C elsewhere). It is also set as aria-keyshortcuts. Showing it does not bind it: handle the key yourself.
shortcutLabelsPartial<KbdLabels>defaultKbdLabelsKey names for the shortcut (i18n). Every other string, for translation: shortcutLabels={{ mac: "…" }}; omitted keys keep the English of defaultKbdLabels. All 4 keys of KbdLabels are listed in the key table under the props table.
descriptionReactNodeNoneShows the second line under the label.
trailingReactNodeNoneAnything else at the end of the row (a badge, a count).
PropTypeDefaultDescription
active (required)booleanNoneShow the pill (pass the item's highlighted state).
tone"neutral" | "danger""neutral""danger" tints it red, for destructive items.
classNamestringNoneAdds extra classes to the pill.
PropTypeDefaultDescription
insetbooleanfalseIndent to line up with item labels that sit after an icon.
PropTypeDefaultDescription
iconReactNodeNoneShows an icon before the label (decorative).
descriptionReactNodeNoneShows the second line under the label.
trailingReactNodeNoneAnything else at the end of the row (a badge, a count).
insetbooleanNoneLeave the icon slot empty so the label lines up with items that have icons.
PropTypeDefaultDescription
shortcutstring | readonly string[]NoneKeyboard shortcut to show, e.g. "mod+c" (⌘C on a Mac, Ctrl+C elsewhere). It is also set as aria-keyshortcuts. Showing it does not bind it: handle the key yourself.
shortcutLabelsPartial<KbdLabels>defaultKbdLabelsKey names for the shortcut (i18n). Every other string, for translation: shortcutLabels={{ mac: "…" }}; omitted keys keep the English of defaultKbdLabels. All 4 keys of KbdLabels are listed in the key table under the props table.
descriptionReactNodeNoneShows the second line under the label.
trailingReactNodeNoneAnything else at the end of the row (a badge, a count).
PropTypeDefaultDescription
labelsPartial<MenuLabels>defaultMenuLabelsSpoken text. Merged over defaultMenuLabels. Every other string, for translation: labels={{ submenu: "…" }}; omitted keys keep the English of defaultMenuLabels. All 2 keys of MenuLabels are listed in the key table under the props table.
anchorElement | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | nullNoneElement to position against instead of the trigger.
sideOffsetnumber4Gap between the trigger and the menu, in px (each part has its own default).
alignOffsetnumber-6Shift along the alignment axis, in px (each part has its own default).
collisionPaddingnumber12Space kept from the viewport edges, in px.
positionerClassNamestringNoneClasses for the positioner (the fixed element around the popup).
PropTypeDefaultDescription
iconReactNodeNoneShows an icon before the label (decorative).
descriptionReactNodeNoneShows the second line under the label.
trailingReactNodeNoneAnything else at the end of the row (a badge, a count).
insetbooleanNoneLeave the icon slot empty so the label lines up with items that have icons.

Keyboard

KeysAction
Enter/Space/Arrow DownOpen the menu from the trigger.
Arrow Down/Arrow UpMove between items; the list wraps.
Home/EndJump to the first or last item.
Type a letterJump to the next item that starts with it (typeahead).
Enter/SpaceRun the highlighted item (a checkbox or radio item toggles and keeps the menu open).
Arrow Right/Arrow LeftOpen or close a submenu (flipped in right-to-left pages).
EscapeClose the menu and return focus to the trigger.

Accessibility

  • role="menu" with menuitem, menuitemcheckbox and menuitemradio children (Base UI); the trigger has aria-haspopup="menu" and aria-expanded.
  • Give an icon-only trigger an aria-label. A disabled item stays visible and is skipped by the arrow keys.
  • Shortcut hints are shown as keys and exposed through aria-keyshortcuts for the visitor's platform; touch rows are 44 px tall.

All exports on this page

  • GlideHighlightScope — Gives every MenuHighlight pill inside it one shared tracker.
  • Menu — Dropdown menu on Base UI Menu: arrow keys, Home/End, typeahead, submenus, Escape and focus return.
  • MenuCheckboxItem — A toggle (menuitemcheckbox).
  • MenuContent — The glass popup of a Menu, portalled to the end of the body and positioned next to the trigger.
  • MenuGroup — Groups related items inside a menu; put a MenuLabel first to name it.
  • MenuHeader — A non-interactive header row, e.g.
  • MenuHighlight — The highlight pill.
  • MenuItem — One action in a menu.
  • MenuLabel — Heading for a MenuGroup or MenuRadioGroup (place it inside the group).
  • MenuLinkItem — A menu item that is a real link (<a href>): opens in a new tab with Cmd/Ctrl-click, shows the URL on hover.
  • MenuRadioGroup — Holds the chosen value of a set of MenuRadioItems: controlled with value + onValueChange, or uncontrolled with defaultValue.
  • MenuRadioItem — One choice in a MenuRadioGroup (menuitemradio).
  • MenuSeparator — A hairline between groups of items.
  • MenuSub — Wraps a MenuSubTrigger and its MenuSubContent.
  • MenuSubContent — The submenu popup.
  • MenuSubTrigger — The item that opens a submenu: hover, click, → (← in RTL) or Enter.
  • MenuTrigger — The element that opens a Menu.
  • createMenuHandle — For triggers that live outside <Menu>: const handle = createMenuHandle().
  • defaultMenuLabels — English defaults of MenuLabels ("Submenu", "Submenu, level 2").

When to use the dropdown menu

  • Use it as an animated dropdown menu for a row actions button in a table, where a three-dot trigger opens Edit, Duplicate and Delete, with tone="danger" marking the destructive item.
  • Use it for an account menu in a navbar, with a MenuHeader for the signed-in user, MenuLinkItem entries for Settings and Billing, and a MenuSub for a theme or language choice.
  • Use it for view options with MenuCheckboxItem and MenuRadioGroup, such as showing or hiding columns and choosing a sort order, with the chosen state kept in your own React state.
  • Skip it when the user is choosing a value for a form field; Select is built for that, and an application menu bar with File, Edit and View belongs in Menubar.
  • Pair it with Button via render on MenuTrigger, KbdShortcut or the shortcut prop to show key hints, and AlertDialog to confirm items that cannot be undone.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .