Skip to main content
The Placeholder extension adds placeholder text to empty nodes in your editor. It’s useful for providing hints about what content should go in different parts of the document. The placeholder can be static text or a dynamic function that returns different text based on the node context.

Installation

The Placeholder extension is included in the @tiptap/extensions package.

Basic Usage

Styling the Placeholder

The extension adds CSS classes that you can style:

Configuration Options

string | function
The placeholder content. Can be a static string or a function that returns different text based on the node context.Default: 'Write something …'As a string:
As a function:
Function parameters:
  • editor: The editor instance
  • node: The ProseMirror node
  • pos: Position in the document
  • hasAnchor: Whether the cursor is in this node
string
The CSS class added to empty nodes when the entire editor is empty.Default: 'is-editor-empty'
string
The CSS class added to individual empty nodes.Default: 'is-empty'
string
The data attribute name used for the placeholder text. Will be prepended with data- and converted to kebab-case.Default: 'placeholder'
boolean
Whether the placeholder should only be shown when the editor is editable.Default: true
boolean
Whether the placeholder should only be shown for the node containing the cursor.Default: true
boolean
Whether to show placeholders for all descendant nodes or just direct children.Default: false

Advanced Examples

Different Placeholders for Different Nodes

Context-Aware Placeholders

Show All Empty Nodes

Custom Styling

Read-Only Editor with Placeholders

Dynamic Placeholder Based on Editor State

Position-Based Placeholders

Source Code

View the source code on GitHub: