Skip to main content
SuperDoc ships with a ready-made toolbar. Point it at a container, and you get formatting controls, font pickers, and document actions out of the box.
Want full control over the toolbar UI? On React, use Custom UI: typed hooks (useSuperDocCommand), per-command re-renders, custom commands. For non-React stacks, use the headless toolbar.

Quick start

Configuration

string
CSS selector for the toolbar container (e.g. '#toolbar'). Must be a string selector, not a DOM element reference.
string[]
default:"['left', 'center', 'right']"
Layout regions for button placement
Object
Custom button arrangement by group
string[]
default:"[]"
Button names to exclude from toolbar
Object
default:"{}"
Custom SVG icons for buttons. See Icon Customization.
Object
default:"{}"
Custom tooltips and labels
Array
default:"[]"
Available font options in font dropdown. See Font Configuration.
boolean
default:"true"
Auto-hide buttons on small screens
boolean
default:"false"
Size relative to container instead of window
Array
default:"[]"
Custom button definitions. See Custom Buttons.
boolean
default:"false"
Show the formatting marks (pilcrow) button in the toolbar. Off by default. Distinct from layoutEngineOptions.showFormattingMarks, which controls whether the marks render in the document.

Available buttons

Use button names with excludeItems, groups, and icons configuration.

Text formatting

button
Toggle bold (Ctrl+B)
button
Toggle italic (Ctrl+I)
button
Toggle underline (Ctrl+U)
button
Toggle strikethrough
button
Clear all formatting
button
Format painter: copy formatting from selection

Font controls

dropdown
Font family selector
dropdown
Font size selector (8–96pt)
dropdown
Text color picker
dropdown
Background highlight color picker

Paragraph

dropdown
Text alignment (left, center, right, justify)
button
Toggle bullet list
button
Toggle numbered list
button
Decrease indent
button
Increase indent
dropdown
Line height selector (1, 1.15, 1.5, 2, 2.5, 3)
dropdown
Quick paragraph styles (Normal, Heading 1, etc.)

Insert

Insert or edit link
button
Upload and insert image
dropdown
Insert table via grid selector
dropdown
Table editing actions (add/delete rows/columns, merge/split cells, etc.)

Tools

button
Undo last action
button
Redo last action
Search in document
dropdown
Zoom level (50%–200%)
button
Toggle document ruler
button
Toggle formatting marks (pilcrow) display. Hidden by default; enable with modules.toolbar.showFormattingMarksButton: true.
dropdown
Switch between editing/viewing/suggesting modes

Track changes

button
Accept tracked change at current selection
button
Reject tracked change at current selection

Custom buttons

Basic button

string
required
'button' or 'dropdown'
string
required
Unique button identifier
string
Hover text
string
SVG icon string
string
default:"'center'"
Layout group: 'left', 'center', or 'right'
string | function
required
Command name or handler function receiving { item, argument, option }
Array
required
Dropdown items, each with label (display text), key (value), and optional icon
boolean
default:"true"
Show dropdown arrow

Toggle button

boolean
default:"false"
Initial active state
string
Icon when active

Icon customization

Icons should be 24x24 viewBox SVGs with fill="currentColor" for proper theming

Font configuration

The toolbar dropdown lists only what you register in fonts. Imported documents don’t auto-populate the list: if a user opens a .docx that uses Cambria and Cambria isn’t registered, the current-selection indicator shows “Cambria” but the user can’t pick it from the dropdown.
Array
Registering a font in fonts makes it selectable. It doesn’t load any font files. To make the font actually render with its real glyphs, load it on your host page via @font-face or a <link> to a font service. Fonts the browser can’t find fall back to the CSS generic.

Loading web fonts

Any font loaded on your host page is available inside the editor. Load it, then register it in fonts:

Substituting Microsoft Office fonts

Most .docx files use Cambria, Calibri, or Aptos: fonts bundled with Word on desktop but not present in browsers. Google hosts free metric-compatible replacements: Download the .woff2 files from Google Fonts, host them with your app, and alias each substitute to the original Word name via @font-face. The browser will then render real Carlito/Tinos glyphs whenever the document asks for Calibri/Cambria: no document or SuperDoc changes needed.
Self-hosting the .woff2 files is more reliable than linking to Google Fonts CDN URLs directly: those URLs change when Google updates a font version.

Responsive behavior

The toolbar adapts at these widths: Use responsiveToContainer: true to size based on the toolbar container instead of the window.

Role-based controls

The toolbar automatically adapts based on the user’s role:

API methods

getToolbarItemByName

Get a toolbar item by its name.

getToolbarItemByGroup

Get all toolbar items in a layout group.

updateToolbarState

Refresh all button states based on the current editor state.

setZoom

Set the editor zoom level programmatically through the owning SuperDoc instance.

destroy

Clean up toolbar resources and event listeners.

exception

Fired when an error occurs during a toolbar action.

Full example

Custom Toolbar Example

Runnable example: custom button groups, excluded items, and a custom clear-formatting button