Skip to main content

Overview

The FloatingMenu component renders a menu that appears when the cursor is on an empty line in the editor. It’s commonly used to provide quick access to block-level formatting options like headings, lists, or inserting media.

Type Signature

Props

Editor | null
required
The editor instance. If not provided, the component will attempt to use the editor from React context via useCurrentEditor.
string | PluginKey
default:"'floatingMenu'"
Unique identifier for this floating menu plugin. Use different keys if you have multiple floating menus.
number
default:"250"
Delay in milliseconds before the menu position is updated. This debounces position updates for better performance.
number
default:"60"
Delay in milliseconds before the menu position is updated on window resize. This debounces resize events for better performance.
function | null
default:"null"
Function that determines whether the menu should be shown. Receives editor state and selection information.
Default behavior: Shows when the cursor is in an empty text block at the root level and the editor has focus.
HTMLElement | (() => HTMLElement)
The DOM element to append the menu to. Useful when you need to render the menu in a specific container for z-index or overflow reasons.Default: The editor’s parent element.
object
Floating UI configuration options for positioning and behavior.
React.ReactNode
required
The content to render inside the floating menu.
React.HTMLAttributes<HTMLDivElement>
All standard HTML div attributes (className, style, etc.) are supported.

Usage Examples

Basic Usage

Block Type Selector

Styled Floating Menu

Custom shouldShow Logic

Slash Command Style

With Icons

Custom Positioning

Styling

CSS Example

Notion-Style Plus Button

Important Notes

The FloatingMenu uses Floating UI for positioning, which provides intelligent placement that avoids overflow and adjusts to viewport constraints.
When clicking buttons inside the floating menu, make sure to use .focus() in your command chains to prevent the editor from losing focus, which would hide the menu.
The default shouldShow behavior only shows the menu on empty text blocks at the root level. Customize this behavior with the shouldShow prop to match your use case.

Default Behavior

By default, the floating menu:
  • Shows when the cursor is in an empty text block at root depth
  • Hides when text is typed
  • Hides when the editor loses focus
  • Positions itself to the right of the cursor
  • Only appears when the editor is editable
The menu will NOT show:
  • In empty list items
  • In code blocks
  • In nested content
  • When text exists in the block
  • When the editor doesn’t have focus

Comparison with BubbleMenu