Add a link popover UI component
Upgrade to v3
To use UI components or templates you need to upgrade to Editor version 3.x. See the upgrade guide for more details.
A popover for creating and editing links.
Install
You can add the component via Tiptap CLI (for Vite or Next.js)
npx @tiptap/cli add link-popoverManual Integration
For frameworks other than Vite or Next.js, add the component manually from the open-source repository.
Import styles
This component requires you to import our styles which were added to styles/keyframe-animation.scss and styles/_variables.scss.
Usage
import { EditorContent, EditorContext, useEditor } from '@tiptap/react'
import { StarterKit } from '@tiptap/starter-kit'
import { Link } from '@/components/tiptap-extension/link-extension'
import { LinkPopover } from '@/components/tiptap-ui/link-popover'
import '@/components/tiptap-node/paragraph-node/paragraph-node.scss'
export default function MyEditor() {
const editor = useEditor({
immediatelyRender: false,
extensions: [StarterKit, Link.configure({ openOnClick: false })],
content: `
<p>Click the button to open the link popover.</p>
<p><a href="https://www.tiptap.dev">Tiptap</a></p>
`,
})
return (
<EditorContext.Provider value={{ editor }}>
<div className="tiptap-button-group" data-orientation="horizontal">
<LinkPopover />
</div>
<EditorContent editor={editor} role="presentation" />
</EditorContext.Provider>
)
}Props
| Name | Type | Default | Description |
|---|---|---|---|
| editor | Editor | null | null | The Tiptap editor instance |
| hideWhenUnavailable | boolean | false | Whether the popover is in a floating context |
| onOpenChange | (isOpen: boolean) => void | - | Callback when popover open state changes |
| autoOpenOnLinkActive | boolean | true | Whether to open popover when a link is selected |
Requirements
Used reference components
use-tiptap-editor(hook)tiptap-utils(lib)button(primitive)popover(primitive)separator(primitive)link-icon(icon)trash-icon(icon)corner-down-left-icon(icon)external-link-icon(icon)
Open source feature(s)
@tiptap/extension-link