tiptap/docs/api/extensions/focus.md

29 lines
1.3 KiB
Markdown
Raw Normal View History

# Focus
2021-01-25 17:35:52 +08:00
[![Version](https://img.shields.io/npm/v/@tiptap/extension-focus.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-focus)
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-focus.svg)](https://npmcharts.com/compare/@tiptap/extension-focus?minimal=true)
2021-06-30 04:12:51 +08:00
The Focus extension adds a CSS class to focused nodes. By default it adds `.has-focus`, but you can change that.
Note that its only a class, the styling is totally up to you. The usage example below has some CSS for that class.
## Installation
```bash
# with npm
npm install @tiptap/extension-focus
# with Yarn
yarn add @tiptap/extension-focus
```
## Settings
2021-02-06 01:13:51 +08:00
| Option | Type | Default | Description |
| --------- | -------- | ------------- | ---------------------------------------------------------------------------- |
| className | `String` | `'has-focus'` | The class that is applied to the focused element. |
2021-02-06 01:14:18 +08:00
| mode | `String` | `'all'` | Apply the class to `'all'`, the `'shallowest'` or the `'deepest'` node. |
## Source code
2021-04-21 21:31:11 +08:00
[packages/extension-focus/](https://github.com/ueberdosis/tiptap/blob/main/packages/extension-focus/)
## Usage
<tiptap-demo name="Extensions/Focus"></tiptap-demo>