Skip to main content

Overview

The FloatingMenu 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 element
  • duration - Animation duration
  • zIndex - 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
By default, the menu is appended to document.body.
function
default:"null"
A callback function that determines whether the floating menu should be visible. Receives an object with:
  • editor - The editor instance
  • view - The ProseMirror EditorView
  • state - Current editor state
  • oldState - Previous editor state
Return 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 pluginKey values
  • The menu is removed from the DOM and re-parented by the plugin when shown
  • Use shouldShow to customize when the menu appears based on editor state
  • The floating menu is ideal for slash commands or block-level content insertion

See Also