Skip to main content
Brand and assets
Build
Monitor and contribute
/
Component library
  • All components
  • Buttons & actions
  • Forms & inputs
  • Layout & containers
  • Overlays
    • BottomSheet
    • DialogBox
    • DropdownMenu
    • Modal
    • Popover
    • Screen
    • SidebarModal
    • Tooltip
  • Feedback & status
  • Data display
  • Typography
  • Accessibility
  • Contrib
  • Deprecated
  • Overlays
  • DropdownMenu

DropdownMenu

Collects secondary actions behind one trigger. Use when a screen has more actions than it can show.

Health
Component health
Source
View on Github
Design
View Figma
Storybook
View in Storybook
Playground
No Example
Accessibility

partially-compliant

Platform
Universal
Accessibility issues
The focus is trapped correctly and keyboard navigation is rightly managed. The first menu item is not focused when the menu is opened.
  • Overview
  • Props
  • Figma

Usage​

Trigger Types​

ButtonTrigger​

DropdownMenu.ButtonTrigger is the most common trigger. Use it when you have a text label. It accepts all regular Button props:

<DropdownMenu>
<DropdownMenu.ButtonTrigger size="sm" hasDropdownArrow>
Actions
</DropdownMenu.ButtonTrigger>
<DropdownMenu.Content>{/* Items... */}</DropdownMenu.Content>
</DropdownMenu>

IconButtonTrigger​

DropdownMenu.IconButtonTrigger is for icon-only triggers. It accepts all IconButton props. Always provide an aria-label for accessibility:

<DropdownMenu>
<DropdownMenu.IconButtonTrigger icon="MoreVert" aria-label="Open actions menu" />
<DropdownMenu.Content>{/* Items... */}</DropdownMenu.Content>
</DropdownMenu>

SemanticButtonTrigger​

DropdownMenu.SemanticButtonTrigger allows using a fully custom element as the trigger while maintaining accessibility. Useful when you need a completely custom trigger appearance:

<DropdownMenu>
<DropdownMenu.SemanticButtonTrigger>
<Box sx={{ padding: "$px8", backgroundColor: "$indigo50", borderRadius: "$px12" }}>
<HStack gap="$px4" sx={{ alignItems: "center" }}>
<Text size="$text200" weight="medium">
Custom trigger
</Text>
<Icon visual="ArrowDropdown" size="size16" />
</HStack>
</Box>
</DropdownMenu.SemanticButtonTrigger>
<DropdownMenu.Content>{/* Items... */}</DropdownMenu.Content>
</DropdownMenu>

Disabled items​

Custom items​

By default, DropdownMenu.Item renders a button. It's possible to render a different element instead. It's especially useful to render a link (or a Link from react-router-dom):

Complex items​

Each items renders text by default. It's possible to pass a more complex element as a child instead:

Items onPress​

It is possible to add an onPress prop to the DropdownMenu.Item component:

Inner scroll​

It's possible to add a scroll to some port of the DropdownMenu:

Focusable elements​

The DropdownMenu controls the focus of its children. It's especially important to ensure accessibility and keyboard navigation. If you need to add a focusable element inside the DropdownMenu (e.g. a text input), you need to use the DropdownMenu.Focusable to ensure the focus is managed correctly.

<DropdownMenu>
<DropdownMenu.ButtonTrigger>{/* ... */}</DropdownMenu.ButtonTrigger>
<DropdownMenu.Content>
<DropdownMenu.Focusable>
<TextInput placeholder="Search" value={search} onChange={setSearch} />
</DropdownMenu.Focusable>
<Spacer size="$px4" />
<DropdownMenu.Item>Settings</DropdownMenu.Item>
{/* More items... */}
</DropdownMenu.Content>
</DropdownMenu>

Mobile​

On mobile, DropdownMenu.Content will be displayed in a BottomSheet. Please note that the DropdownMenu must be controlled in order to work on mobile.

Playground​

Loading...
tip
This component is universal, its usage is the same in murray and murray/mobile.

DropdownMenu props

NameTypeDefault ValueDescriptionUsage count
children*PopoverProps["children"]
disableFocusPopoverProps["disableFocus"]
hoverablePopoverProps["hoverable"]
keepChildrenMountedPopoverProps["keepChildrenMounted"]
onOpenChangePopoverProps["onOpenChange"]
openPopoverProps["open"]
placementPopoverProps["placement"]

DropdownMenuContent props

No props

DropdownMenuFocusable props

No props

DropdownMenuItem props

No props

DropdownMenuScrollView props

No props

DropdownMenuButtonTrigger props

No props

DropdownMenuIconButtonTrigger props

No props

DropdownMenuSemanticButtonTrigger props

No props
Edit this page
Previous
DialogBox
Next
Modal
  • Usage
  • Trigger Types
    • ButtonTrigger
    • IconButtonTrigger
    • SemanticButtonTrigger
  • Disabled items
  • Custom items
  • Complex items
  • Items onPress
  • Inner scroll
  • Focusable elements
  • Mobile
  • Playground