---
title: "Add a popover to your highlights"
description: "Add a popover in which you can select a highlight. Add this UI component to your Tiptap Editor."
---

> This page is for Tiptap 2.x. [See the latest version of this page.](https://tiptap.dev/docs/ui-components/components/color-highlight-popover.md)

# Add a popover to your highlights

Add a popover in which you can select a highlight. Add this UI component to your Tiptap Editor.

> **Upgrade to v3**
>
> To use UI components or templates you need to upgrade to Editor version 3.x. See the [upgrade
> guide](https://tiptap.dev/docs/resources/whats-new) for more details.

A popover for selecting text highlight colors.

> **Interactive demo:** [color highlight popover](https://template.tiptap.dev/preview/tiptap-ui/color-highlight-popover)

## Install

You can add the component via Tiptap CLI (for Vite or Next.js)

```bash
npx @tiptap/cli add color-highlight-popover
```

### Manual Integration

For frameworks other than Vite or Next.js, add the component manually from the [open-source repository](https://github.com/ueberdosis/tiptap-ui-components/tree/main/apps/web/src/components/tiptap-ui/color-highlight-popover).

### Import styles

This component requires you to import our styles which were added to `styles/keyframe-animation.scss` and `styles/_variables.scss`.

## Usage

```tsx
import { EditorContent, EditorContext, useEditor } from '@tiptap/react'
import { StarterKit } from '@tiptap/starter-kit'
import { Highlight } from '@tiptap/extension-highlight'
import { ColorHighlightPopover } from '@/components/tiptap-ui/color-highlight-popover'

import '@/components/tiptap-node/paragraph-node/paragraph-node.scss'

export default function MyEditor() {
  const editor = useEditor({
    immediatelyRender: false,
    extensions: [StarterKit, Highlight.configure({ multicolor: true })],
    content: `
        <p style="text-align: left">
            <mark data-color="var(--tt-color-highlight-purple)" style="background-color: var(--tt-color-highlight-purple); color: inherit">
                <span class="selection">Highlight text</span>
            </mark>
            <span class="selection"> </span>
            <mark data-color="var(--tt-color-highlight-red)" style="background-color: var(--tt-color-highlight-red); color: inherit">
                <span class="selection">in</span>
            </mark>
            <span class="selection"> </span>
            <mark data-color="var(--tt-color-highlight-green)" style="background-color: var(--tt-color-highlight-green); color: inherit">
                <span class="selection">different</span>
            </mark>
            <span class="selection"> </span>
            <mark data-color="var(--tt-color-highlight-blue)" style="background-color: var(--tt-color-highlight-blue); color: inherit">
                <span class="selection">colors</span>
            </mark>
            <span class="selection"> to draw attention to key points.</span>
        </p>
        `,
  })

  return (
    <EditorContext.Provider value={{ editor }}>
      <div className="tiptap-button-group" data-orientation="horizontal">
        <ColorHighlightPopover />
      </div>

      <EditorContent editor={editor} role="presentation" />
    </EditorContext.Provider>
  )
}
```

## Props

| Name                | Type             | Default                  | Description                                  |
| ------------------- | ---------------- | ------------------------ | -------------------------------------------- |
| editor              | Editor \| null   | null                     | The Tiptap editor instance                   |
| colors              | HighlightColor[] | DEFAULT_HIGHLIGHT_COLORS | Array of highlight color options             |
| hideWhenUnavailable | boolean          | false                    | Whether the popover is in a floating context |

## Requirements

Used reference components

- `use-menu-navigation` (hook)
- `use-tiptap-editor` (hook)
- `button` (primitive)
- `popover` (primitive)
- `separator` (primitive)
- `tiptap-utils` (lib)
- `highlighter-icon` (icon)
- `ban-icon` (icon)

Open source feature(s)

- `@tiptap/extension-highlight`
