Skip to main content
On this page

DropdownMenu

A menu that appears below a trigger with selectable items.

import { DropdownMenu } from "@ninna-ui/overlays";

pnpm add @ninna-ui/overlays@latest
Includes @ninna-ui/core. CSS setup required.View source

Usage

Import and use the DropdownMenu component in your application.

import { DropdownMenu } from "@ninna-ui/overlays";
import { Button , Code } from "@ninna-ui/primitives";
export default function Example() {
return (
<DropdownMenu>
<DropdownMenu.Trigger asChild>
<Button variant="outline">Open Menu</Button>
</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item>Profile</DropdownMenu.Item>
<DropdownMenu.Item>Settings</DropdownMenu.Item>
<DropdownMenu.Separator />
<DropdownMenu.Item>Sign out</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu>
);
}

Basic

A simple dropdown menu with items and a separator.

Live preview

Groups & Labels

Organize menu items with groups, labels, and separators.

Live preview

Checkbox Items

Menu items that can be toggled on and off.

Live preview

Radio Items

Mutually exclusive selection within a radio group.

Live preview

Disabled Items

Items can be disabled to prevent interaction.

Live preview

API Reference

Complete list of props for the DropdownMenu component and its sub-components.

DropdownMenu (Root)

PropTypeDefaultDescription
children*ReactNode—DropdownMenu content (Trigger, Content, etc.)
openboolean—Controlled open state
defaultOpenbooleanfalseDefault open state (uncontrolled)
onOpenChange(open: boolean) => void—Callback when open state changes
modalbooleantrueWhether the dropdown is modal
dir'ltr' | 'rtl''ltr'Reading direction

DropdownMenu.Content

PropTypeDefaultDescription
side'top' | 'right' | 'bottom' | 'left''bottom'Which side to place the menu
sideOffsetnumber4Distance from trigger in pixels
align'start' | 'center' | 'end''start'Alignment along the side
loopbooleantrueWhether to loop keyboard navigation
avoidCollisionsbooleantrueWhether to avoid collisions with viewport boundary
classNamestring—Additional CSS classes

DropdownMenu.Trigger

PropTypeDefaultDescription
asChildbooleanfalseRender as child element instead of wrapping button

DropdownMenu.Item

PropTypeDefaultDescription
disabledbooleanfalseWhether the item is disabled
destructivebooleanfalseWhether the item uses danger styling
onSelect(event: Event) => void—Callback when the item is selected
textValuestring—Text value for typeahead search

DropdownMenu.CheckboxItem

PropTypeDefaultDescription
checkedboolean | 'indeterminate'—Whether the item is checked
onCheckedChange(checked: boolean) => void—Callback when checked state changes
disabledbooleanfalseWhether the item is disabled
onSelect(event: Event) => void—Callback when the item is selected
textValuestring—Text value for typeahead search

DropdownMenu.RadioGroup

PropTypeDefaultDescription
valuestring—Current selected value
onValueChange(value: string) => void—Callback when value changes

DropdownMenu.RadioItem

PropTypeDefaultDescription
value*string—Value of the radio item
disabledbooleanfalseWhether the item is disabled
onSelect(event: Event) => void—Callback when the item is selected
textValuestring—Text value for typeahead search

DropdownMenu.Label

PropTypeDefaultDescription
insetbooleanfalseWhether the label is inset (indented to align with items)

Accessibility

  • Uses role="menu" with proper ARIA attributes
  • Arrow keys navigate between items, Enter/Space selects
  • Typeahead support - type to jump to matching items
  • Escape key closes the menu
  • Sub menus open with Arrow Right and close with Arrow Left
  • Disabled items are skipped during keyboard navigation
  • Checkbox and radio items announce their state to screen readers