Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

thebigk's avatar
Level 13

How to make TipTap editor show in browser?

I'm trying to include TipTap editor in my laravel project; and I can't seem to get the editor (buttons, menus etc.) to show up. The content defined in JS does show up; but the editor itself doesn't.

I wish to know how are you using TipTap in your projects; and how are you styling it with Tailwind. Here's my specific requirement -

  1. The content should be rendered using Tailwind's Typography plugin (I can do this)
  2. Style the editor menus, buttons etc.?

Here's how my editor is being rendered -

/* TIP-TAP Editor */
import { Editor } from '@tiptap/core'
import StarterKit from '@tiptap/starter-kit'

const editor = new Editor({
    element: document.querySelector('.element'),
    extensions: [
        StarterKit,
    ],
    editorProps: {
        attributes: {
            class: 'prose prose-sm sm:prose lg:prose-lg xl:prose-2xl m-5 focus:outline-none',
        },
    },
    content: `
    <h2>
      Hi there,
    </h2>
    <p>
      this is a basic <em>basic</em> example of <strong>tiptap</strong>. Sure, there are all kind of basic text styles you’d probably expect from a text editor. But wait until you see the lists:
    </p>
    <ul>
      <li>
        That’s a bullet list with one …
      </li>
      <li>
        … or two list items.
      </li>
    </ul>
    <p>
      Isn’t that great? And all of that is editable. But wait, there’s more. Let’s try a code block:
    </p>
<pre><code class="language-css">body {
  display: none;
}</code></pre>
    <p>
      I know, I know, this is impressive. It’s only the tip of the iceberg though. Give it a try and click a little bit around. Don’t forget to check the other examples too.
    </p>
    <blockquote>
      Wow, that’s amazing. Good work, boy! 👏
      <br />
      — Mom
    </blockquote>
  `,
})
0 likes
4 replies
Snapey's avatar

check browser console for errors

Snapey's avatar

@thebigk ignore that

So no error probably means you are not initialising the editor code. You have created editor object, but where do you call it?

thebigk's avatar
Level 13

@Snapey that's was my first check. The editor is getting initialized well; otherwise I'd not see the text on my browser. The editor is hooked to the .element class. I've simply modified the welcome.blade.php of my default laravel project: -

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Laravel</title>

        <!-- Fonts -->
        <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">

        <link rel="stylesheet" href="{{mix('css/app.css')}}">
    </head>
    <body class="antialiased">
        <div class="relative flex items-top justify-center min-h-screen bg-gray-100 dark:bg-gray-900 sm:items-center py-4 sm:pt-0">
            <div class="element">
                <div>
                    <button onclick="editor.chain().focus().toggleBold().run()">
                        Bold
                    </button>
                </div>
            </div>
        </div>
        <script src="{{mix('js/app.js')}}"></script>
    </body>
</html>

Please or to participate in this conversation.