Overview
TheFloatingMenu component renders a menu that appears when the cursor is on an empty line. It’s commonly used to provide quick access to block-level formatting options like headings, images, or other content types.
Signature
Props
Editor
required
The Tiptap editor instance. This prop is required.
string | PluginKey
default:"'floatingMenu'"
A unique key for the ProseMirror plugin. Use this if you need multiple floating menus or want to identify this specific plugin.
number
default:"undefined"
Delay in milliseconds before updating the menu position after cursor movement. Useful for debouncing rapid cursor changes.
number
default:"undefined"
Delay in milliseconds before updating the menu position after a window resize event.
TippyOptions
default:"{}"
Configuration options for the underlying Tippy.js positioning library. Use this to customize the menu’s placement, offset, animation, and other display properties.Common options:
placement- Position relative to reference (e.g., ‘top’, ‘bottom’, ‘left’, ‘right’)offset- Distance from the reference elementduration- Animation durationzIndex- CSS z-index value
Element | (() => Element) | 'parent'
default:"undefined"
The element to append the floating menu to. Can be:
- A DOM element
- A function that returns a DOM element
- The string
'parent'to append to the editor’s parent element
document.body.function
default:"null"
A callback function that determines whether the floating menu should be visible. Receives an object with:
editor- The editor instanceview- The ProseMirror EditorViewstate- Current editor stateoldState- Previous editor state
true to show the menu, false to hide it.By default, the menu shows when the cursor is in an empty paragraph and hides otherwise.Lifecycle
- onMounted: Registers the floating menu plugin with the editor and sets up positioning
- onBeforeUnmount: Unregisters the plugin from the editor
Styling
The component inherits attributes (inheritAttrs: false is set, but attributes are manually applied), allowing you to add custom classes, styles, or other HTML attributes:
Examples
Basic Usage
Styled Floating Menu
Custom shouldShow Logic
With Tippy Options
Insert Media Menu
Multiple Floating Menus
Notes
- The floating menu is automatically positioned near the cursor using Tippy.js
- By default, it shows only when the cursor is in an empty paragraph
- The component renders as a
<div>element that you can style with classes or inline styles - Multiple floating menus can coexist by using different
pluginKeyvalues - The menu is removed from the DOM and re-parented by the plugin when shown
- Use
shouldShowto customize when the menu appears based on editor state - The floating menu is ideal for slash commands or block-level content insertion
See Also
- BubbleMenu - Contextual menu for selected text
- useEditor - Create editor instances
- EditorContent - Render the editor