Skip to content

Strike

The Strike mark applies strikethrough formatting to text. It renders as <s> and parses <s>, <del>, <strike>, and CSS text-decoration: line-through. Included in StarterKit by default.

Select text and apply strikethrough with buttons, keyboard shortcut (Cmd+Shift+S / Ctrl+Shift+S), or type ~~text~~ to trigger the input rule.

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

Click to try it out

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

import { Editor, Document, Paragraph, Text, Strike, 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="strike">${defaultIcons.textStrikethrough}</button>
</div>`;
editorEl.before(toolbar);
// Editor
const editor = new Editor({
element: editorEl,
extensions: [Document, Paragraph, Text, Strike],
content: '<p>This is <s>struck-through</s> text.</p>',
});
// Toggle strike on click
toolbar.addEventListener('click', (e) => {
const btn = (e.target as Element).closest<HTMLButtonElement>('[data-mark]');
if (btn) editor.chain().focus().toggleStrike().run();
});

To disable Strike in StarterKit:

StarterKit.configure({ strike: false })
PropertyValue
ProseMirror namestrike
TypeMark
HTML tag<s>

Strike parses from multiple HTML sources for maximum compatibility:

SourceCondition
<s>Always
<del>Always
<strike>Always
CSS text-decorationValue includes line-through

The <strike> tag is deprecated HTML but still supported for backwards compatibility. The text-decoration style check uses includes('line-through'), so compound values like line-through dotted are also matched.

OptionTypeDefaultDescription
HTMLAttributesRecord<string, unknown>{}Custom HTML attributes added to the rendered <s> element
import { Strike } from '@domternal/core';
const CustomStrike = Strike.configure({
HTMLAttributes: { class: 'my-strike' },
});

Applies strikethrough formatting to the current selection.

editor.commands.setStrike();

Removes strikethrough formatting from the current selection.

editor.commands.unsetStrike();

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

editor.commands.toggleStrike();
// With chaining
editor.chain().focus().toggleStrike().run();
KeyAction
Mod-Shift-SToggle strikethrough (toggleStrike)

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

InputResult
~~text~~Wraps text in strikethrough

Type the closing ~~ to trigger the conversion. The markers are removed and the text between them gets strikethrough formatting.

Strike registers a button in the toolbar with the name strike in group format at priority 170.

ItemTypeCommandIconShortcutActive when
StrikethroughbuttontoggleStriketextStrikethroughMod-Shift-SStrike mark is active on selection
import { Strike } from '@domternal/core';
import type { StrikeOptions } from '@domternal/core';
ExportTypeDescription
StrikeMark extensionThe strikethrough mark extension
StrikeOptionsTypeScript typeOptions for Strike.configure()

@domternal/core - Strike.ts