Skip to content

Italic

The Italic mark applies italic formatting to text. It renders as <em> and parses <em>, <i>, and CSS font-style: italic. Included in StarterKit by default.

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

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

Click to try it out

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

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

To disable Italic in StarterKit:

StarterKit.configure({ italic: false })
PropertyValue
ProseMirror nameitalic
TypeMark
HTML tag<em>

Italic parses from multiple HTML sources for maximum compatibility:

SourceCondition
<em>Always
<i>Unless font-style: normal (Google Docs compatibility)
CSS font-styleValue is italic (case-insensitive)
OptionTypeDefaultDescription
HTMLAttributesRecord<string, unknown>{}Custom HTML attributes added to the rendered <em> element
import { Italic } from '@domternal/core';
const CustomItalic = Italic.configure({
HTMLAttributes: { class: 'my-italic' },
});

Applies italic formatting to the current selection.

editor.commands.setItalic();

Removes italic formatting from the current selection.

editor.commands.unsetItalic();

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

editor.commands.toggleItalic();
// With chaining
editor.chain().focus().toggleItalic().run();
KeyAction
Mod-IToggle italic (toggleItalic)

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

InputResult
*text*Wraps text in italic
_text_Wraps text in italic

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

Italic registers a button in the toolbar with the name italic in group format at priority 190.

ItemTypeCommandIconShortcutActive when
ItalicbuttontoggleItalictextItalicMod-IItalic mark is active on selection
import { Italic } from '@domternal/core';
import type { ItalicOptions } from '@domternal/core';
ExportTypeDescription
ItalicMark extensionThe italic mark extension
ItalicOptionsTypeScript typeOptions for Italic.configure()

@domternal/core - Italic.ts