tiptap: Placeholder not rendering
What’s the bug you are facing?
When the editor is empty, either initially, or after deletion, no placeholder is displayed to the user.
A paragraph node is added with the appropriate classes, and a data-placeholder as set by my configuration, however, there is no displayed placeholder for the user. The Paragraph tag just contains an empty <br/>

How can we reproduce the bug on our side?
Set up basic editor, use @tiptap/extension-placeholder as per docs
Can you provide a CodeSandbox?
No response
What did you expect to happen?
The placeholder text gets displayed when there is no content.
Anything to add? (optional)
No response
Did you update your dependencies?
- Yes, I’ve updated my dependencies to use the latest version of all packages.
Are you sponsoring us?
- Yes, I’m a sponsor. 💖
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 20 (3 by maintainers)
add some CSS to your component
Any guidance on how to style the placeholder with Tailwind?
I’m using this:
The placeholder works but the cursor isn’t placed at the beginning of the placeholder text:
Did you manage to find a solution? Adding “first:before:h-0” to emptyNodeClass worked for me.
Just sharing my tailwind fix - I’m using absolute positioning :
For anyone using Tailwind, the above solution which uses
emptyEditorClassonPlaceholder.configwon’t work as expected. The placeholder will render initially, but if you type something and remove it, it won’t show up anymore.Instead you should just use add the styling to your CSS file. You can add tailwind classes with @apply:
If you are using Tailwinds CSS Add the the custom css to the global css file for tailwinds.
Oh wow, I was trying to hack it via this type of approach, didn’t realize it’s how they want us to actually render it.
Does this seem a little hacky though at first glance? What benefit does this have vs, a default display through just the
PlaceHolder.configure.At the very least I feel this should be made a little more clear in the docs. I completely missed the styles tab in the example myself at 1am last night.
Appreciate the replies everyone. Thanks.
thanks man, I was confused why my tailwind style
(inside tailwind.css)doesn’t work, but applying it toemptyEditorClassworks finePlaceholder text is displayed via a CSS pseudo element, have a look at the demo setup: https://embed.tiptap.dev/preview/Extensions/Placeholder
thank you babe!!! you save my life
@coolcorexix Agreed! Submitted a PR. #3711 👍
this should be mentioned in the doc, the scss file in the example is easy to skip 🤦
I’ve seen a few people with this issue but for me with standard config, cursor shows up at beginning of the input.
Cursor Positioning looks off… (Tailwind)
Fix by changing
before:top-2 before:left-2tobefore:top-3 before:left-3your class should now look like this:
To add to this, if you just wanted to show all available placeholders by default, you could use the following CSS selector: