---
title: "Insert and upload an image with a button"
description: "Add a button that uploads and inserts an image into your Tiptap editor. More in the documentation!"
---

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

# Insert and upload an image with a button

Add a button that uploads and inserts an image into your Tiptap editor. More in the documentation!

> **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 button for inserting and uploading images into the editor.

> **Interactive demo:** [image upload button](https://template.tiptap.dev/preview/tiptap-ui/image-upload-button)

## Installation

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

```bash
npx @tiptap/cli add image-upload-button
```

### 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/image-upload-button).

### 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 { Image } from '@tiptap/extension-image'
import { ImageUploadButton } from '@/components/tiptap-ui/image-upload-button'
import { ImageUploadNode } from '@/components/tiptap-node/image-upload-node'
import { handleImageUpload, MAX_FILE_SIZE } from '@/lib/tiptap-utils'

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

export default function MyEditor() {
  const editor = useEditor({
    immediatelyRender: false,
    extensions: [
      StarterKit,
      Image,
      ImageUploadNode.configure({
        accept: 'image/*',
        maxSize: MAX_FILE_SIZE,
        limit: 3,
        upload: handleImageUpload,
        onError: (error) => console.error('Upload failed:', error),
      }),
    ],
    content: `
        <p>Click the button to upload an image.</p>
        `,
  })

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

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

## Props

| Name          | Type           | Default       | Description                        |
| ------------- | -------------- | ------------- | ---------------------------------- |
| editor        | Editor \| null | null          | The Tiptap editor instance         |
| extensionName | string         | 'imageUpload' | Name of the image upload extension |
| text          | string         | -             | Text to display alongside the icon |

## Requirements

Used reference components

- `use-tiptap-editor` (hook)
- `button` (primitive)
- `image-plus-icon` (icon)
