Insert Toolbar Button

A dropdown toolbar button labeled "Insert" that opens a grouped menu of Plate block and inline elements (paragraphs, headings, tables, code blocks, lists, media, equations, links, dates, and more). Selecting an item inserts it into the editor and returns focus to the editor.

Insert Toolbar Button
LIVE · running in a sandboxed iframe
Installed with shadcn add · 6 workarounds · theme from registry.json
  • applied the registry's theme (tokens, fonts and CSS from the registry preview settings)
  • installed base item https://platejs.org/r/plate-ui.json (registry preview settings)
  • installed npm package @platejs/code-drawing, which the item uses but does not declare
  • installed npm package @platejs/excalidraw, which the item uses but does not declare
  • installed npm package @platejs/footnote, which the item uses but does not declare
  • installed npm package @platejs/suggestion, which the item uses but does not declare
See how it was built

Installation

pnpm dlx shadcn@latest add https://platejs.org/r/insert-toolbar-button.json

Usage

usage.tsx
import { InsertToolbarButton } from '@/components/ui/insert-toolbar-button';export function EditorToolbar() {  return (    <div className='flex items-center gap-1'>      <InsertToolbarButton />    </div>  );}
  • Adding a '+' style block insertion menu to a Plate rich-text editor toolbar.
  • Letting users insert headings, lists, tables, code blocks, images, embeds, equations, or inline elements from one place.
  • Replacing a set of separate per-block toolbar buttons with a single grouped dropdown.
  • Building an editor toolbar in the shadcn/ui style that reuses the project's dropdown-menu and toolbar components.

Examples

Basic toolbar usage

Render the insert button inside an editor toolbar container. It must be rendered inside a Plate editor context because it calls useEditorRef.

basic-toolbar-usage.tsx
import { InsertToolbarButton } from '@/components/ui/insert-toolbar-button';export function BasicToolbar() {  return (    <div className='flex items-center gap-1 border-b p-1'>      <InsertToolbarButton />    </div>  );}

Forcing the menu to be modal

Props are spread onto the underlying DropdownMenu after its defaults, so modal (and open/onOpenChange) can be overridden. Here the menu blocks outside interaction while open.

forcing-the-menu-to-be-modal.tsx
import { InsertToolbarButton } from '@/components/ui/insert-toolbar-button';export function ModalInsertToolbar() {  return (    <div className='flex items-center gap-1 border-b p-1'>      <InsertToolbarButton modal />    </div>  );}

Observing open state

Pass onOpenChange to react when the insert menu opens or closes, for example to track analytics or collapse other toolbar panels.

observing-open-state.tsx
import { InsertToolbarButton } from '@/components/ui/insert-toolbar-button';export function TrackedInsertToolbar() {  return (    <div className='flex items-center gap-1 border-b p-1'>      <InsertToolbarButton        onOpenChange={(open) => {          console.log('insert menu open:', open);        }}      />    </div>  );}

API reference

PropTypeDefaultDescription
...props (DropdownMenuProps)DropdownMenuProps (from @radix-ui/react-dropdown-menu)—All props are spread onto the root DropdownMenu after the component's internal defaults (open, onOpenChange, modal={false}), so any of them can override the defaults. The component takes no other custom props; the menu contents, labels, and insertion behavior are fixed in the source.

Accessibility

  • The trigger is a ToolbarButton with tooltip 'Insert' and pressed={open}, so its open state is conveyed to assistive technology and the tooltip describes the purpose of the icon-only button.
  • Menu items are Radix DropdownMenuItem elements, which provide keyboard navigation (arrow keys, Enter/Space to select, Escape to close) and focus management.
  • Groups are labeled through ToolbarMenuGroup with the visible group names (for example 'Basic blocks' and 'Inline'), giving context to screen reader users.
  • After an item is selected, the component calls editor.tf.focus() so keyboard focus returns to the editor and the user can continue typing.
  • Since the trigger is icon-only, provide a meaningful tooltip or aria-label through ToolbarButton if you customize the component; the default tooltip is 'Insert'.

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Insert Toolbar Button" component (plate/insert-toolbar-button) from its shadcn registry.1. Install it with: npx shadcn@latest add https://platejs.org/r/insert-toolbar-button.json2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: ...props (DropdownMenuProps).Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { InsertToolbarButton } from '@/components/ui/insert-toolbar-button';export function EditorToolbar() {  return (    <div className='flex items-center gap-1'>      <InsertToolbarButton />    </div>  );}```

Files & dependencies

  • src/registry/ui/insert-toolbar-button.tsx
registryDependenciesdropdown-menuhttps://platejs.org/r/toolbar.jsonhttps://platejs.org/r/transforms.json

Looks similar, elsewhere