Skip to content

Dropdown

⋯

Dropdown Menu renders the Nesra Basic, Submenu, Multiple, and Destructive action-menu layouts and the Dropdown Item Notif Read and Notif Unread items on Base UI Menu. Multiple shows a long, scrollable list of actions. It does not select multiple values. Use Select or Combobox when a trigger chooses a value.

import { DropdownMenu } from "@nesra/ui/dropdown-menu";
export function Actions({ onExport }: { onExport: () => void }) {
return (
<DropdownMenu>
<DropdownMenu.Trigger>Actions</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Item onClick={onExport}>Export report</DropdownMenu.Item>
</DropdownMenu.Content>
</DropdownMenu>
);
}

DropdownMenu is also exported from @nesra/ui. Content renders the portal, positioner, and popup. Trigger renders a button by default. Its render prop can compose a custom control.

DropdownMenu
├── DropdownMenu.Trigger
└── DropdownMenu.Content
├── DropdownMenu.Item
├── DropdownMenu.NotificationItem
├── DropdownMenu.Group
│ ├── DropdownMenu.Label
│ └── DropdownMenu.Item
├── DropdownMenu.Separator
└── DropdownMenu.Sub
├── DropdownMenu.SubTrigger
└── DropdownMenu.SubContent

Select an action

Use open and onOpenChange when the page needs to observe or control whether the menu is open.

Menu is closed

Give an icon-only trigger an accessible name with aria-label.

Select an action

render can supply a custom button. Give the avatar button an aria-label.

Set closeOnClick={false} on an action that should leave the menu open after activation.

Refresh count: 0

Content forwards side, align, and sideOffset to the positioner. Viewport collisions can change the rendered placement.

DropdownMenu.Sub owns each nested menu. SubTrigger renders the trailing chevron.

The popup limits its height to the available viewport space and scrolls long menus.

variant="destructive" changes the item text color. The consuming application owns the action and any confirmation step.

Icons, shortcuts, and supporting text are children of the item. Set label for typeahead when the item contains more than its name.

DropdownMenu.NotificationItem renders the Figma Notif Unread and Notif Read items: a bordered icon tile, the title, a short description, and a time. unread adds the unread dot and the bell-with-dot icon. The example marks a notification as read when it is activated. The application owns that state.

The menu follows the Figma Dropdown Menu roles in both modes: the popup uses --nesra-foundation-bg-neutral with --nesra-stroke-border and shadow-nesra-lg, highlighted items use --nesra-action-secondary-hover, DropdownMenu.Label uses --nesra-text-support, and DropdownMenu.Separator uses --nesra-stroke-divider. A notification item uses --nesra-text-body for the title and --nesra-text-support for the description and time. Its icon tile is --nesra-surface-card-bg-neutral with a --nesra-stroke-border border and shadow-nesra-xs. The unread dot and unread icon use --nesra-icon-brand-primary, and the read icon uses --nesra-icon-muted. Item icons inherit the item text color, so they read as icon-neutral, icon-disabled, or icon-destructive with the item state. When an icon sits on a fixed fill that does not switch with the theme, set text-nesra-icon-static-dark or text-nesra-icon-static-white on that icon. Content on --nesra-action-primary-default, such as the avatar trigger example, uses text-nesra-text-on-brand.

  • Give the trigger an accessible name. Icon-only triggers require aria-label.
  • Arrow keys move focus among items, typing finds an item by label, and Enter or Space activates it. Right Arrow opens a submenu. Left Arrow returns to its trigger. Escape closes the menu and returns focus to the trigger by default.
  • Disabled items remain discoverable by keyboard with aria-disabled, but cannot activate.
  • DropdownMenu.Label names its containing group. Keep item text or the Base UI label prop meaningful for typeahead and assistive technology.
  • Icons, supporting text, shortcuts, and counts belong in item children.
  • A notification item is named by its title. An unread item is named “Unread,” followed by the title, so the state does not depend on the dot alone. The description and time describe the item through aria-describedby. The unread text is translatable through NesraI18nProvider or unreadLabel.
  • The application owns notification read status and updates it when an action requires that change.

Owns the menu’s open state and forwards Base UI Menu Root props.

Prop Type Default Effect
open boolean — Controls whether the menu is open.
defaultOpen boolean false Sets the initial uncontrolled state.
onOpenChange (open: boolean, details) => void — Runs when the open state changes.

Opens the menu. Accepts Base UI Menu Trigger button props, including render for composition and disabled. Forwards its ref to the button and accepts className.

Renders a portal, positioner, and popup. The ref points to the popup. className styles the popup, container selects the portal host, and inherited Base UI Positioner props such as side, align, sideOffset, and collisionPadding control placement. sideOffset defaults to 4px.

The popup renders at 250px width, constrained by the viewport. side defaults to "bottom" for a root menu, and align defaults to "center". Base UI flips the popup near viewport edges.

Invokes the inherited onClick handler. disabled blocks activation and closeOnClick defaults to true. Other Base UI Menu Item props, including label for typeahead, are forwarded.

Prop Type Default Effect
variant "default" | "destructive" "default" Changes the text color for destructive actions.

The item accepts className and forwards its ref to the rendered item.

A DropdownMenu.Item with the Figma notification layout. It forwards Base UI Menu Item props, including onClick, disabled, closeOnClick, and className, and forwards its ref. It does not accept children or variant.

Prop Type Default Effect
title ReactNode Required Medium 14px header. Names the item.
description ReactNode — Regular 12px text in text-support. Describes the item.
time ReactNode — Regular 12px text at the end. Describes the item after description.
icon ReactNode Bell, or bell with dot 16px icon inside the 28px tile.
unread boolean false Shows the 6px unread dot, sets data-unread, and prefixes the name.
unreadLabel string Translated "Unread" Text announced before the title when unread is set.
label string title when a string Typeahead text.

Groups related items. Accepts Base UI Menu Group props and className and forwards its ref to the group element.

Names its containing group. Accepts Base UI Menu Group Label props and className and forwards its ref to the label element.

Separates item groups. Accepts Base UI Menu Separator props and className and forwards its ref to the separator element.

Owns a nested menu and forwards Base UI Menu Submenu Root props. Place SubTrigger and SubContent inside this root.

Opens the nested menu and renders a trailing chevron. Accepts Base UI Menu Submenu Trigger props and className and forwards its ref to the rendered trigger.

Uses the same props and rendering as DropdownMenu.Content inside a submenu.

Rendered parts accept className as a string or a Base UI state callback. Their classes are merged with Nesra’s defaults.

Named prop types are available from @nesra/ui and @nesra/ui/dropdown-menu for wrapping public parts, such as DropdownMenuItemProps, DropdownMenuNotificationItemProps, and DropdownMenuContentProps. SubContent uses DropdownMenuContentProps.

The menu uses the light color roles, typography, layout scale, and shape and elevation tokens.