Toolbar
These options control how the editor toolbar is laid out, how it handles overflow, and where it is positioned.
Options
| Option | Type | Default | Description |
|---|---|---|---|
toolbar | boolean/string/string[] | 'undo redo | blocks | bold italic | alignleft aligncenter alignright | indent outdent | bullist numlist | code | table help' | Toolbar button layout. Pass a string of space-separated button names with | as group separators, an array of strings for multiple rows, or false to hide the toolbar. |
toolbar_mode | string | 'floating' (mobile: 'scrolling') | How the toolbar handles overflow when buttons do not fit. Options: 'floating' (overflow menu), 'sliding' (slide-out drawer), 'scrolling' (horizontal scroll), 'wrap' (wrap to next line). |
toolbar_groups | object | {} | Named groups of toolbar buttons that collapse into a single group button. Each key is the group name and the value is an object with an items array. |
toolbar_location | string | 'auto' | Where the toolbar is placed. 'auto' uses the default position, 'top' forces it above the content, 'bottom' places it below. |
toolbar_persist | boolean | false | Keep the toolbar of an inline editor visible even when the editor loses focus. |
toolbar_sticky | boolean | same as inline | Make the toolbar stick to the top of the viewport when scrolling past the editor. Enabled by default for inline editors. |
toolbar_sticky_offset | number | 0 | Offset in pixels from the top of the viewport when the toolbar is in sticky mode. Useful when the page has a fixed header. |
fixed_toolbar_container | string | '' | CSS selector for an element that should contain the toolbar, detaching it from the editor frame. Only works with inline editors. |
fixed_toolbar_container_target | HTMLElement | — | Direct DOM element reference for the fixed toolbar container. Use instead of fixed_toolbar_container when you already have a reference. |
ui_mode | string | 'combined' | Controls how the editor UI is structured. |
Example
editor42.init({
selector: 'textarea',
toolbar: 'undo redo | blocks | bold italic underline | alignleft aligncenter alignright | bullist numlist | link image',
toolbar_mode: 'sliding',
toolbar_sticky: true,
toolbar_sticky_offset: 64,
toolbar_location: 'top'
});