Skip to main content

Overview

SlashCommandMenu provides the / command experience: when a user types / at the start of a block, a menu appears near the caret with available block types. The component is self-managed — it handles the trigger, keyboard listeners, filtering, and floating positioning. Use it as a child of YooptaEditor so it can read the editor’s plugins via useYooptaEditor().
Slash command menu demo

Features

  • Self-managed — Opens on /, filters as you type, keyboard navigation (↑ ↓ Enter Esc)
  • Auto-generated items — Reads block types from editor plugins (or pass custom items)
  • Compound components — Root, Content, List, Group, Item, Empty, Separator, Footer
  • Floating positioning — Inline positioning via Floating UI
  • TypeScript — Full type safety

Installation

Basic Usage

Use SlashCommandMenu as a child of YooptaEditor. The editor must be created with createYooptaEditor({ plugins, marks }); plugins and marks are not passed to YooptaEditor.

API Reference

SlashCommandMenu (Root)

Root component. Renders nothing by itself; use the children render function to build the UI.
Props: Children render props:

SlashCommandMenu.Content

Floating content panel. Positions the menu near the caret.

SlashCommandMenu.List

Scrollable list container.

SlashCommandMenu.Item

Menu item. Selecting it inserts or toggles to that block type.
Props: value, title, description?, icon?, className?

SlashCommandMenu.Empty

Shown when there are no matching items.
Optional footer (e.g. keyboard hints).

SlashCommandMenu.Group / SlashCommandMenu.Separator

Group items or add a separator between groups.

Behavior

  • Typing / at the start of a block opens the menu
  • Typing more characters filters items (e.g. /hea → headings)
  • Arrow Up/Down — Navigate items
  • Enter — Confirm selection (insert or toggle block)
  • Escape — Close the menu

Examples

Custom items

Pass a custom list instead of using plugin-derived items:

Custom trigger

Use a different trigger character:

Styling

Uses the same base CSS variables as other UI components. Override with className or CSS variables:

Best Practices

  • Use SlashCommandMenu as a child of YooptaEditor so it has access to the editor context.
  • Create the editor with createYooptaEditor({ plugins, marks }); do not pass plugins or marks to YooptaEditor.
  • Provide clear title and description for each item (from plugin options.display or custom items).

FloatingBlockActions

Add block from hover actions

ActionMenuList

“Turn into” menu from toolbar or block options