Skip to content

Bold

The Bold mark applies bold formatting to text. It renders as <strong> and parses <strong>, <b>, and CSS font-weight styles (600+, bold, bolder). Included in StarterKit by default.

Select text and apply bold with buttons, keyboard shortcut (Cmd+B / Ctrl+B), or type **text** to trigger the input rule.

With the default theme enabled. Click the B toolbar button or use Cmd+B / Ctrl+B.

Click to try it out

Bold is included in StarterKit, so it works out of the box. To use it standalone:

import { Editor, Document, Paragraph, Text, Bold, defaultIcons } from '@domternal/core';
import '@domternal/theme';
const editorEl = document.getElementById('editor')!;
// Toolbar
const toolbar = document.createElement('div');
toolbar.className = 'dm-toolbar';
toolbar.innerHTML = `<div class="dm-toolbar-group">
<button class="dm-toolbar-button" data-mark="bold">${defaultIcons.textB}</button>
</div>`;
editorEl.before(toolbar);
// Editor
const editor = new Editor({
element: editorEl,
extensions: [Document, Paragraph, Text, Bold],
content: '<p>This is <strong>bold</strong> text.</p>',
});
// Toggle bold on click
toolbar.addEventListener('click', (e) => {
const btn = (e.target as Element).closest<HTMLButtonElement>('[data-mark]');
if (btn) editor.chain().focus().toggleBold().run();
});

To disable Bold in StarterKit:

StarterKit.configure({ bold: false })
PropertyValue
ProseMirror namebold
TypeMark
HTML tag<strong>

Bold parses from multiple HTML sources for maximum compatibility:

SourceCondition
<strong>Always
<b>Unless font-weight: normal or 400 (Google Docs compatibility)
CSS font-weightNumeric value >= 600, or bold/bolder
OptionTypeDefaultDescription
HTMLAttributesRecord<string, unknown>{}Custom HTML attributes added to the rendered <strong> element
import { Bold } from '@domternal/core';
const CustomBold = Bold.configure({
HTMLAttributes: { class: 'my-bold' },
});

Applies bold formatting to the current selection.

editor.commands.setBold();

Removes bold formatting from the current selection.

editor.commands.unsetBold();

Toggles bold formatting on the current selection. Applies bold if not active, removes it if active.

editor.commands.toggleBold();
// With chaining
editor.chain().focus().toggleBold().run();
KeyAction
Mod-BToggle bold (toggleBold)

Mod is Cmd on macOS and Ctrl on Windows/Linux.

InputResult
**text**Wraps text in bold
__text__Wraps text in bold

Type the closing ** or __ to trigger the conversion. The markers are removed and the text between them becomes bold.

Bold registers a button in the toolbar with the name bold in group format at priority 200.

ItemTypeCommandIconShortcutActive when
BoldbuttontoggleBoldtextBMod-BBold mark is active on selection
import { Bold } from '@domternal/core';
import type { BoldOptions } from '@domternal/core';
ExportTypeDescription
BoldMark extensionThe bold mark extension
BoldOptionsTypeScript typeOptions for Bold.configure()

@domternal/core - Bold.ts