React

Menu

A component that provides a list of options or actions users can take.

Available since@seed-design/react@2.0.0, @seed-design/css@2.0.0

Installation

npx @seed-design/cli@latest add ui:menu

Usage

Menu is structured as follows:

import {
  MenuRoot,
  MenuTrigger,
  MenuContent,
  MenuGroup,
  MenuGroupLabel,
  MenuItem,
} from "seed-design/ui/menu";
<MenuRoot>
  <MenuTrigger>...</MenuTrigger>
  <MenuContent>
    <MenuGroup>
      <MenuGroupLabel>Group Title</MenuGroupLabel>
      <MenuItem label="Item 1" />
      <MenuItem label="Item 2" />
    </MenuGroup>
    <MenuGroup>
      <MenuItem label="Item 3" />
    </MenuGroup>
  </MenuContent>
</MenuRoot>
  • MenuRoot: Manages the menu's state (open/closed) and position.
  • MenuTrigger: Trigger that opens and closes the menu when clicked.
  • MenuAnchor: Provides only the positioning reference point for the menu and does not include open/close behavior. Use instead of MenuTrigger when you need to directly control the trigger behavior.
  • MenuContent: Floating container that wraps menu items.
  • MenuGroup: Groups related items together. All MenuItem must be inside a MenuGroup.
  • MenuGroupLabel: Displays the group title.
  • MenuItem: Individual menu item.

Props

Prop

Type

children?React.ReactNode
disabled?boolean | undefined
open?boolean | undefined
defaultOpen?boolean | undefined
onOpenChange?((open: boolean, details?: MenuChangeDetails) => void) | undefined

Prop

Type

Prop

Type

Prop

Type

positionerContainer?React.RefObject<HTMLElement | null> | undefined

Prop

Type

Prop

Type

Prop

Type

prefixIcon?React.ReactNode
labelReact.ReactNode
description?React.ReactNode
suffixIcon?React.ReactNode
disabled?boolean | undefined

Examples

Trigger

<MenuTrigger> sets the aria-haspopup="menu" attribute and automatically sets the aria-expanded attribute based on the Menu's open state. This attribute is useful for assistive technologies like screen readers.

Size

The size of MenuRoot is set by size. (default: medium)

responsive is a value where size automatically switches based on screen width. In products that support multiple screen widths, use size=responsive to adapt.

With Description

Add supplementary descriptions to items using the description prop of MenuItem.

Tone

Set the tone of items using the tone prop of MenuItem.

Disabled Items

Disable specific items using the disabled prop of MenuItem.

Placement

Set the position of the menu using the placement prop of MenuRoot. The default is "bottom".

The maximum height of the menu is determined by the smaller of the specified maximum height and the remaining screen space around the trigger (or MenuAnchor). If there are many items, the menu scrolls within itself. The menu is positioned to avoid the notch and home indicator areas.

Anchor

The children of MenuAnchor are used only for positioning the Menu, and unlike MenuTrigger, it does not include click to open/close behavior.

You must use the open prop in a controlled manner to directly manage the open/closed state.

By default, Menu closes when a click (mouse environment) or drag (touch environment) occurs outside the Menu.

In the example below, conditions are added to the onOpenChange callback so the menu does not close even when clicking outside the area.

Match Width

Using the matchReferenceWidth prop of MenuRoot, the menu width matches the width of the reference element (Trigger or Anchor).

onOpenChange Details

details is provided as the second argument to onOpenChange.

reason

When opening (open: true)

  • "trigger": Opened by MenuTrigger

When closing (open: false)

  • "trigger": Closed by MenuTrigger
  • "escapeKeyDown": ESC key pressed
  • "interactOutside": Click outside area
  • "itemClick": Menu item clicked
  • "cascadeDismiss": Cascade close due to parent layer closing

Table of contents