# Italic {#italic}

Source: [Add an italic button to a React editor · Yurich](https://leeyujoo.com/yurich/features/italic/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

Add emphasis or distinguish a title.

## Try it {#try-it}

Select “Yurich” and click **Italic**. The selected word is stored as `<em>Yurich</em>`. Click the button again to remove the emphasis.

## Add it to your editor {#setup}

Enable `Italic` to add emphasis to selected text. Connect your button to `toggleItalic` and keep the selection when the pointer presses the button.

```tsx
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 {#behavior}

`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.

[Features](https://leeyujoo.com/yurich/features/)
