Menu

Menu is a component that displays a common dropdown menu.

Usage

import { Menu } from "@yamada-ui/react"
<Menu.Root>
  <Menu.Trigger />
  <Menu.ContextTrigger />
  <Menu.Anchor />
  <Menu.Content>
    <Menu.Header />
    <Menu.Group>
      <Menu.Item>
        <Menu.Label />
        <Menu.Indicator />
        <Menu.Command />
      </Menu.Item>
    </Menu.Group>
    <Menu.Separator />
    <Menu.OptionGroup>
      <Menu.OptionItem />
    </Menu.OptionGroup>
    <Menu.Footer />
  </Menu.Content>
</Menu.Root>

Use Items

Change Size

Handle Selection Event

To handle selection event, use onSelect.

Add Dividers

Grouping

Display Icons

Display Commands

Set Selectable Items

Nested Menu

Use Context Menu

Display Menu on Different Element

Here display Popover

Disable Close on Select

To disable the close on select, set closeOnSelect to false.

Set Initial Focus

To set initial focus, pass a Ref to initialFocusRef.

Change Placement

To change the display position, set placement to "start", "end-end", etc. By default, "end-start" is set.

Change Animation

To change the animation, set animationScheme to "inline-start", "block-end", etc. By default, "scale" is set.

Change Offset

To change the offset, set a value to gutter or offset.

Change Duration

To change the duration, set a numerical value (seconds) to duration.

Access Internal State

To access internal state, pass a function to the children of Menu.Root.

Disable Close on Outside Click

To disable closing when clicking outside, set closeOnBlur to false.

Disabling Items

To disable items, set disabled to true.

To add header or footer, set ReactNode to header or footer of Menu.Content.

Control

Props

Accessibility

Currently, this section is being updated due to the migration of v2.