shadcn-labs

Markdown Toolbar

Text

About

A toolbar button for a Tiptap rich text editor that imports, exports, and copies the document's content as Markdown.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Markdown Toolbar to your project and fits it to your theme.

Code

How Markdown Toolbar is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import MarkdownToolbar from "@/components/ui/markdown";
import { Markdown } from "@/components/ui/markdown-utils/markdown-core";
import { EditorContent, useEditor } from "@tiptap/react";
import { StarterKit } from "@tiptap/starter-kit";

export default function MarkdownDemo() {
  const editor = useEditor({
    immediatelyRender: false,
    extensions: [StarterKit, Markdown.configure({ pasteMarkdown: true })],
    content:
      "# Welcome\n\nThis editor can **import**, **export**, and **copy** its content as Markdown. Try the button in the toolbar below.\n\n- Works with lists\n- And `inline code`\n\n> Paste markdown text directly into the editor too.",
    contentType: "markdown",
  });

  return (
    <div className="w-full max-w-xl rounded-lg border border-border bg-background text-foreground">
      <div className="flex items-center gap-1 border-b border-border p-1.5">
        <MarkdownToolbar editor={editor} filename="document.md" />
      </div>
      <EditorContent
        editor={editor}
        className="p-4 text-sm leading-6 [&_.ProseMirror]:outline-none [&_.ProseMirror]:min-h-[140px] [&_h1]:text-xl [&_h1]:font-semibold [&_h1]:mb-2 [&_ul]:list-disc [&_ul]:pl-5 [&_blockquote]:border-l-2 [&_blockquote]:border-border [&_blockquote]:pl-3 [&_blockquote]:text-muted-foreground [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_p]:mb-2"
      />
    </div>
  );
}

Dependencies

More by shadcn-labs

View all
  • Email Progress Bar

    Email Progress Bar

    8
  • PDF Section

    PDF Section

  • PDF Badge

    PDF Badge

  • PDF Stack

    PDF Stack

  • Rich Text Editor

    Rich Text Editor

  • Coupons With Centered Text

    Coupons With Centered Text

  • Stripe Receipt Email

    Stripe Receipt Email

  • Masonry Product Detail

    Masonry Product Detail

More in Text

View all
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    134
  • Blur Reveal

    Blur Reveal

    395
  • Reveal Text

    Reveal Text

    165
  • Scroll Fill Headline

    Scroll Fill Headline

    66
  • Astryx Chat Tokenized Text

    Astryx Chat Tokenized Text

    14
  • Text Reveal

    Text Reveal

    405
  • Motion Blur Text

    Motion Blur Text

    48
  • Liquid Text

    Liquid Text

    277