Displays a menu of actions or options triggered by a button. Use dropdown menus for contextual actions, navigation options, and selection interfaces where space is limited.
This component is built on Radix UI Dropdown Menu. For the full primitive API reference, see the Radix documentation.
Installation
shellUsage
tsxAnatomy
The dropdown menu is composed of several parts:
tsxProps
Root
Trigger
Content
Item
CheckboxItem
RadioGroup
RadioItem
Sub
SubTrigger
SubContent
Accepts the same props as Content.
Variants
Solid
Default variant with an opaque background for standard interfaces.
tsxSoft
Subtle background with reduced contrast for content-heavy interfaces.
tsxSizes
Size 1
Compact size for dense interfaces and toolbars.
tsxSize 2
Standard size for most interfaces.
tsxColors
Use the color prop on items to communicate intent. Destructive actions should use red or crimson.
tsxMaterial
Solid
Opaque background for standard interfaces.
tsxTranslucent
Frosted glass effect for depth over images or dynamic backgrounds. Use highContrast for readability.
tsxShortcuts
Display keyboard shortcuts using the shortcut prop on items.
tsxLabels
Use Label to add section headings within the menu.
tsxGroups
Use Group to logically group related items.
tsxCheckbox Items
Use CheckboxItem for toggleable options within the menu.
tsxRadio Items
Use RadioGroup and RadioItem for mutually exclusive options.
tsxSubmenus
Use Sub, SubTrigger, and SubContent for nested navigation.
tsxSubmenu Behavior
The submenuBehavior prop controls how submenus appear and interact. There are two modes:
Cascade (Default)
Submenus open as floating panels to the side of the trigger, using portals. This is the standard desktop behavior.
tsxDrill-Down
Submenus replace the current menu content inline with a back button, similar to mobile navigation patterns. This prevents horizontal overflow on small screens.
tsxThe label prop on Sub sets the back button text. It defaults to "Back" if not provided.
Responsive
Use a responsive object to switch between behaviors at different breakpoints. This provides the best experience on both mobile and desktop.
tsxBreakpoint values: initial (default), xs (520px), sm (768px), md (1024px), lg (1280px), xl (1640px).
Trigger Icon
Use TriggerIcon to add a dropdown indicator to custom triggers.
tsxVirtualization
For menus with many items (hundreds or thousands), use the virtualized prop with VirtualMenu to render only visible items. This dramatically improves performance by keeping the DOM small.
Simple Usage
Use itemLabel for basic text items:
tsxHow It Works
- Set
virtualizedonContentto skip the built-in ScrollArea - Use
VirtualMenuwith your items array - Provide
itemLabel(for simple text) orrenderItem(for custom rendering) - Set a fixed
heighton VirtualMenu (required for virtualization)
VirtualMenu Props
You must provide either itemLabel or renderItem.
Custom Rendering with renderItem
For custom item layouts, pass a memoized component to renderItem:
tsxImportant: The renderItem component must:
- Be wrapped in
React.memofor optimal performance - Spread
styleand other props ontoVirtualMenu.Item
RenderItem Props
Props passed to your renderItem component:
Variable Height Items
Use a function for estimatedItemSize when items have different heights:
tsxKeyboard Navigation
VirtualMenu supports full keyboard navigation:
Controlled
Control the open state for programmatic menu management.
tsxAccessibility
Dropdown Menu follows the WAI-ARIA Menu Button pattern and includes:
Keyboard Navigation
Screen Readers
- Proper
role="menu"androle="menuitem"attributes aria-haspopupon trigger indicates menu availabilityaria-expandedreflects open statearia-checkedfor checkbox and radio itemsaria-disabledfor disabled items- Focus management returns to trigger on close
Focus Management
- Focus is trapped within menu when open
- Focus returns to trigger when menu closes
- Submenus manage focus independently
Changelog
Added
- Built on Radix UI Dropdown Menu primitive
materialprop for solid/translucent backgrounds- Integrated
ScrollAreafor long menus shortcutprop for keyboard shortcut display usingKbdcomponent- Theme integration for accent colors and materials
- Drill-down submenu behavior via
submenuBehaviorprop for mobile-friendly navigation labelprop onSubfor custom back button text in drill-down mode- Responsive submenu behavior with breakpoint-based switching between cascade and drill-down modes
- Drill-down animations with direction-aware slide transitions (slides from right when entering submenu, from left when going back)
- Respects
prefers-reduced-motionfor drill-down animations - Virtualization support via
virtualizedprop andVirtualMenucomponent for rendering large lists efficiently
Deprecated
panelBackgroundprop in favor ofmaterialprop