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().

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
UseSlashCommandMenu 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.
| Prop | Type | Description |
|---|---|---|
children | ReactNode | ((props) => ReactNode) | Content or render function receiving items and groupedItems |
trigger | string | Trigger character (default: '/') |
items | SlashCommandItem[] | Optional custom items (otherwise from plugins) |
onSelect | (item: SlashCommandItem) => void | Called when an item is selected |
className | string | Custom CSS classes |
| Property | Type | Description |
|---|---|---|
items | SlashCommandItem[] | Flat list of block actions |
groupedItems | Map<string, SlashCommandItem[]> | Items grouped by category |
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.
value, title, description?, icon?, className?
SlashCommandMenu.Empty
Shown when there are no matching items.
SlashCommandMenu.Footer
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 withclassName or CSS variables:
Best Practices
- Use
SlashCommandMenuas a child ofYooptaEditorso it has access to the editor context. - Create the editor with
createYooptaEditor({ plugins, marks }); do not passpluginsormarkstoYooptaEditor. - Provide clear
titleanddescriptionfor each item (from pluginoptions.displayor customitems).

