slash-editor
Components

Slash Menu

The '/' block-insert command palette — shadcn Command in an anchored Popover, driven by useSlashMenu.

Installation

bunx --bun shadcn@latest add @slash-editor/slash-menu

Usage

The core ranks items and owns the keyboard state machine; useSlashMenu(editor) exposes that state plus a caret anchor, and this component renders it.

const menu = useSlashMenu(editor);
// { open, query, items, activeIndex, activeItem, anchor, setActiveIndex, select, close }

Custom items are plain objects — run receives the editor and the range covering /query:

useSlashEditor({
  blockKit: {
    slash: {
      items: [
        ...defaultSlashItems,
        {
          id: "date-stamp",
          title: "Date stamp",
          group: "Basic blocks",
          aliases: ["today", "date"],
          run: ({ editor, range }) =>
            editor.chain().focus().insertContentAt(range, new Date().toLocaleDateString()).run(),
        },
      ],
    },
  },
});

On this page