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 { Document, Paragraph, Text, Strike } from '@domternal/core';
import { DomternalEditor, DomternalToolbar } from '@domternal/vanilla';
import '@domternal/theme';
const editorEl = document.getElementById('editor')!;
const toolbarEl = document.createElement('div');
editorEl.before(toolbarEl);
const dm = new DomternalEditor(editorEl, {
extensions: [Document, Paragraph, Text, Strike],
content: '<p>This is <s>struck-through</s> text.</p>',
});
new DomternalToolbar(toolbarEl, { editor: dm.editor });

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