Component

Dropdown Menu

A dropdown menu with items, separators, labels, and disabled items. Accessible keyboard navigation and ARIA support. Uses the headless @refraction-ui/dropdown-menu core.

Examples

A menu with labels, separators, actionable items, and a disabled item.

Installation

$pnpm add @refraction-ui/react

Usage

tsx
import {
  DropdownMenu, DropdownMenuTrigger, DropdownMenuContent,
  DropdownMenuItem, DropdownMenuSeparator, DropdownMenuLabel,
} from '@refraction-ui/react'

export function MyComponent() {
  return (
    <DropdownMenu>
      <DropdownMenuTrigger>Open</DropdownMenuTrigger>
      <DropdownMenuContent>
        <DropdownMenuLabel>Actions</DropdownMenuLabel>
        <DropdownMenuSeparator />
        <DropdownMenuItem onSelect={() => {}}>Edit</DropdownMenuItem>
        <DropdownMenuItem onSelect={() => {}}>Delete</DropdownMenuItem>
      </DropdownMenuContent>
    </DropdownMenu>
  )
}

Props

PropTypeDefaultDescription
openboolean--Controlled open state.
defaultOpenbooleanfalseInitial open state.
onOpenChange(open: boolean) => void--Callback on open change.
childrenReactNode--Trigger + Content with items.
DropdownMenuContent align'start' | 'center' | 'end''start'The menu is portalled to <body> and anchored under the trigger (following scroll/resize); align picks which trigger edge it lines up with. A pointer press outside closes it.
DropdownMenuContent sideOffsetnumber4Gap in px between trigger and menu.

DropdownMenuTrigger props

PropTypeDefaultDescription
asChildbooleanfalseMerge the trigger props/behavior onto the child element instead of rendering a <button> around it. Use with styled triggers like <Button> to avoid nesting a button in a button.

DropdownMenuItem props

PropTypeDefaultDescription
disabledbooleanfalseDisables the item: removes it from tab order and blocks selection.
onSelect() => void--Callback fired when the item is selected via click or Enter/Space, before the menu closes.