Skip to content

prosekit/react/menu

import {
  MenuItem,
  MenuPopup,
  MenuPositioner,
  MenuRoot,
  MenuSubmenuRoot,
  MenuSubmenuTrigger,
  MenuTrigger,
} from 'prosekit/react/menu'

<MenuRoot>
  <MenuTrigger>...</MenuTrigger>
  <MenuPositioner>
    <MenuPopup>
      <MenuItem>...</MenuItem>
      <MenuSubmenuRoot>
        <MenuSubmenuTrigger>...</MenuSubmenuTrigger>
        <MenuPositioner>
          <MenuPopup>
            <MenuItem>...</MenuItem>
          </MenuPopup>
        </MenuPositioner>
      </MenuSubmenuRoot>
    </MenuPopup>
  </MenuPositioner>
</MenuRoot>

Props for the MenuItem React component.

value?: string

The unique value for this menu item.

""

disabled?: boolean

Whether this menu item is disabled.

false

closeOnSelect?: boolean

Whether to close the menu when the item is pressed.

true

onSelect?: (event: SelectEvent) => void

Emitted when the the item is selected.


Props for the MenuPopup React component.

eventTarget?: EventTarget | HTMLElement | null

By default, the MenuPopup element will listen for keydown events. You can pass a different element to listen for keydown events.

null


Props for the MenuPositioner React component.

placement?: Placement

The initial placement of the floating element

"bottom-start"

strategy?: "fixed" | "absolute"

The strategy to use for positioning

"absolute"

autoUpdate?: boolean | AutoUpdateOptions

Options to activate auto-update listeners

https://floating-ui.com/docs/autoUpdate

true

hoist?: boolean

Whether to use the browser Popover API to place the floating element on top of other page content.

true

offset?: OffsetOptions

The distance between the reference and floating element.

6

flip?: boolean | Placement[]

Whether to flip the placement in order to keep it in view when the preferred placement(s) will overflow the clipping boundary. You can also provide an array of placements to try sequentially if the preferred placement does not fit.

true

shift?: boolean

Whether the floating element should shift to keep it in view.

true

overlap?: boolean

Whether the floating element can overlap the reference element to keep it in view.

false

fitViewport?: boolean

Whether to constrain the floating element's width and height to not exceed the viewport.

false

sameWidth?: boolean

Whether to constrain the floating element's width so that it matches the reference element.

false

sameHeight?: boolean

Whether to constrain the floating element's height so that it matches the reference element.

false

inline?: boolean

Whether to improve positioning for inline reference elements that span over multiple lines.

false

hide?: boolean

Whether to hide the floating element when the reference element or the floating element is fully clipped.

false

boundary?: Boundary

Describes the clipping element(s) or area that overflow will be checked relative to. Please see https://floating-ui.com/docs/detectoverflow#boundary for more information.

'clippingAncestors'

rootBoundary?: RootBoundary

Describes the root boundary that the element will be checked for overflow relative to. Please see https://floating-ui.com/docs/detectoverflow#rootboundary for more information.

'viewport'

overflowPadding?: number

Describes the virtual padding around the boundary to check for overflow. Please see https://floating-ui.com/docs/detectoverflow#padding for more information.

4

elementContext?: ElementContext

The element that will be used to check for overflow. Please see https://floating-ui.com/docs/detectoverflow#elementcontext for more information.

'floating'

altBoundary?: boolean

Whether to check the alternate elementContext's boundary. Please see https://floating-ui.com/docs/detectoverflow#altboundary for more information.

false


Props for the MenuRoot React component.

defaultOpen?: boolean

Whether the overlay is initially open.

false

open?: boolean | null

Whether the overlay is currently open.

null

disabled?: boolean

Whether the component should ignore user interaction.

false

onOpenChange?: (event: OpenChangeEvent) => void

Emitted when the menu is opened or closed.


Props for the MenuSubmenuRoot React component.

defaultOpen?: boolean

Whether the overlay is initially open.

false

open?: boolean | null

Whether the overlay is currently open.

null

disabled?: boolean

Whether the component should ignore user interaction.

false

onOpenChange?: (event: OpenChangeEvent) => void

Emitted when the submenu is opened or closed.


Props for the MenuSubmenuTrigger React component.

value?: string

The unique value for this submenu trigger in the parent menu.

""

disabled?: boolean

Whether this submenu trigger is disabled.

false


Props for the MenuTrigger React component.

disabled?: boolean

Whether the component should ignore user interaction.

false

onOpenChange?: (event: OpenChangeEvent) => void

Emitted when the menu is opened or closed.

const MenuItem: ForwardRefExoticComponent<MenuItemProps & Omit<HTMLAttributes<MenuItemElement>, "onSelect"> & RefAttributes<MenuItemElement>>

A React component that renders an prosekit-menu-item custom element.


const MenuPopup: ForwardRefExoticComponent<MenuPopupProps & HTMLAttributes<MenuPopupElement> & RefAttributes<MenuPopupElement>>

A React component that renders an prosekit-menu-popup custom element.


const MenuPositioner: ForwardRefExoticComponent<MenuPositionerProps & HTMLAttributes<MenuPositionerElement> & RefAttributes<MenuPositionerElement>>

A React component that renders an prosekit-menu-positioner custom element.


const MenuRoot: ForwardRefExoticComponent<MenuRootProps & HTMLAttributes<MenuRootElement> & RefAttributes<MenuRootElement>>

A React component that renders an prosekit-menu-root custom element.


const MenuSubmenuRoot: ForwardRefExoticComponent<MenuSubmenuRootProps & HTMLAttributes<MenuSubmenuRootElement> & RefAttributes<MenuSubmenuRootElement>>

A React component that renders an prosekit-menu-submenu-root custom element.


const MenuSubmenuTrigger: ForwardRefExoticComponent<MenuSubmenuTriggerProps & HTMLAttributes<MenuSubmenuTriggerElement> & RefAttributes<MenuSubmenuTriggerElement>>

A React component that renders an prosekit-menu-submenu-trigger custom element.


const MenuTrigger: ForwardRefExoticComponent<MenuTriggerProps & HTMLAttributes<MenuTriggerElement> & RefAttributes<MenuTriggerElement>>

A React component that renders an prosekit-menu-trigger custom element.