---
title: "Selection extension"
description: "Use the Selection extension in Tiptap to preserve the selection when the editor is blurred. Learn more in our docs!"
canonical_url: "https://tiptap.dev/docs/editor/extensions/functionality/selection"
---

# Selection extension

Use the Selection extension in Tiptap to preserve the selection when the editor is blurred. Learn more in our docs!

The Selection extension adds a CSS class to the current selection when the editor is blurred. By default it adds `.selection`, but you can change that.

Note that it’s only a class, the styling is totally up to you. The usage example below has some CSS for that class.

> **Interactive demo:** [Selection](https://embed.tiptap.dev/preview/Extensions/Selection)

## Install

```bash
npm install @tiptap/extensions
```

And import it in your editor:

```ts
import { Editor } from '@tiptap/core'
import { Selection } from '@tiptap/extensions'

new Editor({
  extensions: [Selection],
})
```

## Settings

### className

The class that is applied to the current selection.

Default: `'selection'`

```js
Selection.configure({
  className: 'selection',
})
```

## Source code

[packages/extensions/selection/](https://github.com/ueberdosis/tiptap/blob/main/packages/extensions/src/selection/)

## Minimal Install

```js
import { Editor } from '@tiptap/core'
import { Selection } from '@tiptap/extensions/selection'

new Editor({
  extensions: [Selection],
})
```
