Italic
Add emphasis or distinguish a title.
Try it
Select “Yurich” and click Italic. The selected word is stored as <em>Yurich</em>. Click the button again to remove the emphasis.
Live example
Example result
Add it to your editor
Enable Italic to add emphasis to selected text. Connect your button to toggleItalic and keep the selection when the pointer presses the button.
import { EditorContent, EditorProvider, Italic, useEditor, useIsActive } from 'yurich';
export function ItalicEditor() {
const editor = useEditor({
extensions: [Italic],
initialValue: "<p>Yurich is leaning into italic.</p>",
});
const active = useIsActive(editor, 'toggleItalic');
return (
<EditorProvider editor={editor}>
<button
type="button"
aria-pressed={active}
onMouseDown={event => event.preventDefault()}
onClick={() => editor.execute('toggleItalic')}
>
Italic
</button>
<EditorContent ariaLabel="Editor" />
</EditorProvider>
);
}
Behavior to account for
Mod+I runs the same command. Loaded HTML may use <i>, which is normalized to <em> in output. Other marks on the same text can remain in place.