Add a toolbar button

This example shows how to add a custom button to the main toolbar at startup.

Code

<div id="entry-add-toolbar-button"></div>
const app = Redactor('#entry-add-toolbar-button', {
    toolbar: {
        add: {
            preview: {
                title: 'Preview',
                icon: '<svg ...>',
                position: { after: 'add' },
                handler() {
                    app.toast.show('Preview button clicked');
                }
            }
        }
    }
});