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.jsonAccount
Signed in as Ada.
MenuMenuSubMenuItemMenuGroupMenuLabel- +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.
import { Avatar } from "@/components/sheenui/avatar/avatar";
import { Badge } from "@/components/sheenui/badge/badge";
import { Button } from "@/components/sheenui/button/button";
import { Menu, MenuContent, MenuHeader, MenuItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger } from "@/components/sheenui/menu/menu";
// Package build (after the first npm release, or a packed tarball): import { Avatar, Badge, Button, Menu, MenuContent, MenuHeader, MenuItem, MenuSeparator, MenuSub, MenuSubContent, MenuSubTrigger, MenuTrigger } from "@sheenui/theme";
import { CreditCard as CardIcon, ChevronDown as ChevronDownIcon, Cloud as CloudIcon, Link as LinkIcon, LogOut as LogoutIcon, Mail as MailIcon, User as UserIcon, UserPlus as UserPlusIcon } from "lucide-react";
// This example also uses avatar, badge, button: 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
export function Example() {
return (
<Menu>
<MenuTrigger
render={<Button variant="glass" leading={<Avatar name="Ada Lovelace" size="sm" />} trailing={<ChevronDownIcon />} />}
>
Ada Lovelace
</MenuTrigger>
<MenuContent className="w-72">
<MenuHeader>
<b>Ada Lovelace</b>
<span>ada@example.com</span>
</MenuHeader>
<MenuSeparator />
<MenuItem icon={<UserIcon />} shortcut="shift+mod+p">Profile</MenuItem>
<MenuItem icon={<CardIcon />} shortcut="mod+b" trailing={<Badge tone="accent">Pro</Badge>}>
Billing
</MenuItem>
<MenuSeparator />
<MenuSub>
<MenuSubTrigger icon={<UserPlusIcon />}>Invite people</MenuSubTrigger>
<MenuSubContent>
<MenuItem icon={<MailIcon />}>Email</MenuItem>
<MenuItem icon={<LinkIcon />}>Copy invite link</MenuItem>
</MenuSubContent>
</MenuSub>
<MenuItem icon={<CloudIcon />} disabled>API keys</MenuItem>
<MenuSeparator />
<MenuItem icon={<LogoutIcon />} tone="danger" shortcut="shift+mod+q" onClick={() => console.log("sign out")}>
Log out
</MenuItem>
</MenuContent>
</Menu>
);
}Files to copy
8 folders · 10 files · 4 packages
- From
theme/src/ components/menu/components/drawer/parts/sheet.tsxcomponents/kbd/components/status-icons/hooks/{use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{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.tsxcomponents/spinner/hooks/use-magnetic.tsmotion/gate.tslib/{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
import { useState } from "react";
import { Button } from "@/components/sheenui/button/button";
import { Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuTrigger } from "@/components/sheenui/menu/menu";
// Package build (after the first npm release, or a packed tarball): import { Button, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuLabel, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuTrigger } from "@sheenui/theme";
import { ChevronDown as ChevronDownIcon } from "lucide-react";
// This example also uses button: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
export function Example() {
const [toolbar, setToolbar] = useState(true);
const [density, setDensity] = useState("comfortable");
return (
<Menu>
<MenuTrigger render={<Button variant="glass" trailing={<ChevronDownIcon />} />}>View</MenuTrigger>
<MenuContent>
<MenuGroup>
<MenuLabel>Show</MenuLabel>
<MenuCheckboxItem checked={toolbar} onCheckedChange={setToolbar} shortcut="shift+mod+t">
Toolbar
</MenuCheckboxItem>
<MenuCheckboxItem disabled description="Needs a folder">Breadcrumbs</MenuCheckboxItem>
</MenuGroup>
<MenuSeparator />
<MenuRadioGroup value={density} onValueChange={setDensity}>
<MenuLabel>Density</MenuLabel>
<MenuRadioItem value="compact">Compact</MenuRadioItem>
<MenuRadioItem value="comfortable">Comfortable</MenuRadioItem>
<MenuRadioItem value="spacious">Spacious</MenuRadioItem>
</MenuRadioGroup>
</MenuContent>
</Menu>
);
}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
import { Button } from "@/components/sheenui/button/button";
import { CopyIcon } from "@/components/sheenui/description-list/copy-button";
import { Menu, MenuContent, MenuItem, MenuLinkItem, MenuSeparator, MenuTrigger } from "@/components/sheenui/menu/menu";
// Package build (after the first npm release, or a packed tarball): import { Button, CopyIcon, Menu, MenuContent, MenuItem, MenuLinkItem, MenuSeparator, MenuTrigger } from "@sheenui/theme";
import { Ellipsis as DotsIcon, ExternalLink as ExternalIcon, Pencil as PencilIcon, Trash2 as TrashIcon } from "lucide-react";
// This example also uses button, description-list: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json https://lokendra-builds.github.io/sheenui/r/description-list.json
export function Example() {
return (
<Menu>
<MenuTrigger render={<Button variant="ghost" size="icon" aria-label="Actions for Q3 roadmap.pdf" />}>
<DotsIcon />
</MenuTrigger>
<MenuContent align="end">
<MenuItem icon={<PencilIcon />} shortcut="enter">Rename</MenuItem>
<MenuItem icon={<CopyIcon />} shortcut="mod+d">Duplicate</MenuItem>
<MenuLinkItem icon={<ExternalIcon />} href="https://github.com/" target="_blank">
Open on GitHub
</MenuLinkItem>
<MenuSeparator />
<MenuItem icon={<TrashIcon />} tone="danger" shortcut="mod+backspace">Delete</MenuItem>
</MenuContent>
</Menu>
);
}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).
import { Button } from "@/components/sheenui/button/button";
import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from "@/components/sheenui/menu/menu";
// Package build (after the first npm release, or a packed tarball): import { Button, Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from "@sheenui/theme";
// This example also uses button: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/button.json
export function Example() {
return (
<Menu mobile="sheet">
<MenuTrigger render={<Button variant="glass" />}>Options</MenuTrigger>
<MenuContent>
<MenuItem>Rename</MenuItem>
<MenuItem>Duplicate</MenuItem>
<MenuSeparator />
<MenuItem tone="danger">Delete</MenuItem>
</MenuContent>
</Menu>
);
}API
Menu
MenuContent
MenuItem
Inherited Base UI props
MenuCheckboxItem props
MenuHighlight props
MenuLabel props
MenuLinkItem props
MenuRadioItem props
MenuSubContent props
MenuSubTrigger props
Keyboard
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
Related pages
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .