Integrate a button in your Editor

A clickable element that performs an action when activated.

Install

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

npx @tiptap/cli add button

Manual Integration

For frameworks other than Vite or Next.js, add the primitive 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 { Button } from '@/components/tiptap-ui-primitive/button'
import { BoldIcon } from '@/components/icons/bold-icon'

export default function MyComponent() {
  return (
    <Button
      data-style="ghost"
      data-active-state="on"
      tooltip="Bold"
      shortcutKeys="Ctrl+B"
      onClick={() => console.log('Bold clicked')}
    >
      <BoldIcon className="tiptap-button-icon" />
      <span className="tiptap-button-text">Bold</span>
    </Button>
  )
}

Props

Button

NameTypeDefaultDescription
data-stylestringundefinedButton style (e.g., 'ghost', 'primary')
data-active-state'on' | 'off'undefinedButton active state
data-sizestringundefinedButton size (e.g., 'small', 'default')
data-appearancestringundefinedButton appearance
data-disabledbooleanundefinedVisual disabled state
tooltipstringundefinedText displayed in tooltip
shortcutKeysstringundefinedKeyboard shortcut displayed in tooltip