# react-example-toolbar

> Formatting toolbar with common editing actions.

A shadcn/ui block from the [@prosekit](https://prosekit.dev) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/prosekit/react-example-toolbar).

- Page, with a live preview: https://shadcn.exchange/r/prosekit/react-example-toolbar
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/prosekit/react-example-toolbar-light-ce8c31c896a01983.png
- Registry item: https://prosekit.dev/r/react-example-toolbar.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://prosekit.dev/r/react-example-toolbar.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `prosekit`
- Registry items: `https://unpkg.com/prosekit-registry/dist/r/react-sample-sample-uploader.json`, `https://unpkg.com/prosekit-registry/dist/r/react-ui-toolbar.json`

## Files

### `registry/src/react/examples/toolbar/editor.tsx`

```tsx
'use client'

import 'prosekit/basic/style.css'
import 'prosekit/basic/typography.css'

import { createEditor } from 'prosekit/core'
import { ProseKit } from 'prosekit/react'
import { useMemo } from 'react'

import { sampleUploader } from '../../sample/sample-uploader.ts'
import { Toolbar } from '../../ui/toolbar/index.ts'

import { defineExtension } from './extension.ts'

export default function Editor() {
  const editor = useMemo(() => {
    const extension = defineExtension()
    return createEditor({ extension })
  }, [])

  return (
    <ProseKit editor={editor}>
      <div className="box-border h-full w-full min-h-36 overflow-y-hidden overflow-x-hidden rounded-md border border-solid border-gray-200 dark:border-gray-700 shadow-sm flex flex-col bg-[canvas] text-black dark:text-white">
        <Toolbar uploader={sampleUploader} />
        <div className="relative w-full flex-1 box-border overflow-y-auto">
          <div ref={editor.mount} className="ProseMirror box-border min-h-full px-[max(4rem,calc(50%-20rem))] py-8 outline-hidden outline-0 [&_span[data-mention=user]]:text-blue-500 [&_span[data-mention=tag]]:text-violet-500"></div>
        </div>
      </div>
    </ProseKit>
  )
}
```

### `registry/src/react/examples/toolbar/extension.ts`

```ts
import { defineBasicExtension } from 'prosekit/basic'
import { union } from 'prosekit/core'

export function defineExtension() {
  return union(defineBasicExtension())
}

export type EditorExtension = ReturnType<typeof defineExtension>
```

### `registry/src/react/examples/toolbar/index.ts`

```ts
export { default as ExampleEditor } from './editor.tsx'
```
