Formatting Toolbar
The Formatting Toolbar appears whenever you highlight text in the editor.

Changing the Formatting Toolbar
You can change or replace the Formatting Toolbar with your own React component. In the demo below, 2 buttons are added to the default Formatting Toolbar - one to add a blue text/background, and one to toggle code styles.
We first define our custom BlueButton
. The useComponentsContext
hook gets all components used internally by BlockNote, so we want to use Components.FormattingToolbar.Button
for this.
We use the FormattingToolbar
component to create a custom Formatting Toolbar. By specifying its children, we can replace the default buttons in the toolbar with our own.
This custom Formatting Toolbar is passed to a FormattingToolbarController
, which controls its position and visibility (above or below the highlighted text).
Setting formattingToolbar={false}
on BlockNoteView
tells BlockNote not to show the default Formatting Toolbar.
Changing Block Type Select (Dropdown) Items
The first element in the default Formatting Toolbar is the Block Type Select, and you can change the items in it. The demo makes the Block Type Select work for image blocks by adding an item to it.
Here, we use the FormattingToolbar
component but keep the default buttons (we don't pass any children). Instead, we pass our customized Block Type Select items using the blockTypeSelectItems
prop.