Skip to main content
The BubbleMenu extension provides a floating menu that appears when text is selected in the editor. It’s positioned intelligently using Floating UI and supports custom positioning, visibility rules, and framework-specific components for React and Vue.

Installation

Basic Usage

Vanilla JavaScript

React

Vue

Configuration Options

HTMLElement
required
The DOM element that contains your menu.Default: null
PluginKey | string
The plugin key for the bubble menu.Default: 'bubbleMenu'
number
The delay in milliseconds before the menu position should be updated. This can be useful to prevent performance issues.Default: 250
number
The delay in milliseconds before the menu position should be updated on window resize.Default: 60
function
A function that determines whether the menu should be shown or not. If this function returns false, the menu will be hidden, otherwise it will be shown.Parameters:
  • editor: The editor instance
  • element: The menu element
  • view: The ProseMirror EditorView
  • state: The current editor state
  • oldState: The previous editor state (optional)
  • from: Selection start position
  • to: Selection end position
Default: Shows when text is selected and editor has focus
HTMLElement | (() => HTMLElement)
The DOM element to append your menu to. Sometimes the menu needs to be appended to a different DOM context due to accessibility, clipping, or z-index issues.Default: Editor’s parent element
() => VirtualElement | null
A function that returns the virtual element for the menu. This is useful when the menu needs to be positioned relative to a specific DOM element.
object
Configuration options passed to Floating UI for positioning. See Floating UI documentation for full details.Properties:
'absolute' | 'fixed'
Positioning strategy.Default: 'absolute'
string
Menu placement relative to selection. Options: 'top', 'right', 'bottom', 'left', 'top-start', 'top-end', 'right-start', 'right-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end'Default: 'top'
number | object | boolean
Distance in pixels from the selection.Default: 8
object | boolean
Whether to flip the menu to the opposite side if there’s not enough space.Default: {}
object | boolean
Whether to shift the menu along the axis to keep it in view.Default: {}
HTMLElement | Window
The scrollable element that should be listened to when updating the position of the bubble menu.Default: window
() => void
Callback fired when the menu is shown.
() => void
Callback fired when the menu is hidden.
() => void
Callback fired when the menu position is updated.
() => void
Callback fired when the menu is destroyed.

React Component Props

When using the React component, you can pass these props:
Editor
The editor instance. Can be omitted if used inside EditorProvider.
string
The plugin key.Default: 'bubbleMenu'
number
Update delay in milliseconds.
number
Resize delay in milliseconds.
function
Function to determine visibility.
object
Floating UI configuration options.
Plus all standard HTML div attributes (className, style, etc.).

Vue Component Props

Editor
required
The editor instance.
string | Object
The plugin key.Default: 'bubbleMenu'
number
Update delay in milliseconds.
number
Resize delay in milliseconds.
function
Function to determine visibility.
object
Floating UI configuration options.
HTMLElement | Function
Element to append the menu to.
function
Function to get the virtual element for positioning.

Advanced Examples

Custom Visibility Logic

Update Position Programmatically

Multiple Bubble Menus

Custom Positioning

Source Code

View the source code on GitHub: