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

Mash Square's avatar

Quill Toolbar settings with Alpine Js

Hi all I hope you guys have some ideas on how to do this,

I'm not familiar with Alpine JS, but since I needed to use Quill on a view where I have Livewire this solution which seems to work. I need to enable some additional toolbar options like in the second script though (codeBlock, image, video etc):

    <div class="mt-2 bg-white" wire:ignore>
                <div
                    class="h-64"
                    x-data
                    x-ref="quillEditor"
                    x-init="
            quill = new Quill($refs.quillEditor, {theme: 'snow'});
            quill.on('text-change', function () {
              $dispatch('quill-input', quill.root.innerHTML);
            });
          "
                    x-on:quill-input.debounce.500ms="@this.set('body', $event.detail)"
                >
                    {!! $body !!}
                </div>
            </div>

Here is how I would need to configure quill:

<script>
                var toolbarOptions = [
                    ['bold', 'italic', 'underline', 'strike'],        // toggled buttons
                    ['blockquote', 'code-block'],

                    [{ 'header': 1 }, { 'header': 2 }],               // custom button values
                    [{ 'list': 'ordered'}, { 'list': 'bullet' }],
                         // superscript/subscript
                           // outdent/indent
                                 // text direction

                    [{ 'size': ['small', false, 'large', 'huge'] }],  // custom dropdown
                    [{ 'header': [1, 2, 3, 4, 5, 6, false] }],
                    [ 'link', 'image', 'video'],          // add's image support
                    [{ 'color': [] }, { 'background': [] }],          // dropdown with defaults from theme

                    [{ 'align': [] }],

                    ['clean']                                         // remove formatting button
                ];

                var quill = new Quill('#editor', {
                    modules: {
                        toolbar: toolbarOptions
                    },

                    theme: 'snow'
                });
</script>
0 likes
0 replies

Please or to participate in this conversation.