# Underline {#underline}

Source: [Underline text in a React editor · Yurich](https://leeyujoo.com/yurich/features/underline/)

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

Package version: `0.1.2`

Draw a line under selected text.

## Try it {#try-it}

Select “Yurich” and click **Underline**. The output contains `<u>Yurich</u>`. Toggle the same selection again to remove the underline.

## Add it to your editor {#setup}

Enable `Underline` for underlined text. The command is `toggleUnderline`, and `useIsActive` can drive the button’s pressed state.

```tsx
import { EditorContent, EditorProvider, Underline, useEditor, useIsActive } from 'yurich';

export function UnderlineEditor() {
  const editor = useEditor({
    extensions: [Underline],
    initialValue: "<p>Give Yurich a line of its own.</p>",
  });
  const active = useIsActive(editor, 'toggleUnderline');

  return (
    <EditorProvider editor={editor}>
      <button
        type="button"
        aria-pressed={active}
        onMouseDown={event => event.preventDefault()}
        onClick={() => editor.execute('toggleUnderline')}
      >
        Underline
      </button>
      <EditorContent ariaLabel="Editor" />
    </EditorProvider>
  );
}
```

## Behavior to account for {#behavior}

Use `Mod+U` to run the command by keyboard. Choose the `Link` extension and `setLink` when the text needs to navigate to a URL.

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