platejs

Code Leaf

Text

About

An inline code leaf for the Plate editor that renders code snippets with monospace, muted-background styling.

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

Code

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

Usage.tsx

"use client";

import * as React from "react";

import { CodeLeaf } from "@/components/ui/code-node";
import { CodePlugin } from "@platejs/basic-nodes/react";
import { Plate, PlateContent, usePlateEditor } from "platejs/react";

export default function CodeNodeDemo() {
  const editor = usePlateEditor({
    plugins: [CodePlugin.withComponent(CodeLeaf)],
    value: [
      {
        type: "p",
        children: [
          { text: "Run " },
          { text: "npm install platejs", code: true },
          { text: " to get started." },
        ],
      },
    ],
  });

  return (
    <div className="w-full max-w-lg p-8">
      <Plate editor={editor}>
        <PlateContent className="rounded-md border p-4 text-sm outline-none" />
      </Plate>
    </div>
  );
}

Dependencies

More by platejs

View all
  • Math Base Kit

    Math Base Kit

    15
  • Highlight Leaf

    Highlight Leaf

    6
  • Cursor Overlay

    Cursor Overlay

    5
  • Editor

    Editor

    4
  • Link Element

    Link Element

    3
  • Resize Handle

    Resize Handle

    3
  • Inline Combobox

    Inline Combobox

    1
  • List

    List

    1

More in Text

View all
  • Vertical Cut Reveal Characters

    Vertical Cut Reveal Characters

    103
  • Motion Blur Text

    Motion Blur Text

    36
  • NeonRGBTextEffect

    NeonRGBTextEffect

    145
  • Rainbow Text Effect

    Rainbow Text Effect

    47
  • Blur Reveal

    Blur Reveal

    302
  • Text Reveal

    Text Reveal

    27
  • Random Letter Swap

    Random Letter Swap

    46
  • Text Color

    Text Color

    546