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