Typix LogoTypix
Overlays

SlashDropdownMenu

`/`-trigger command palette for inserting headings, lists, quotes, code blocks, and custom items.

SlashDropdownMenu pairs with the extension-slash-command extension. It ships with eight built-in items (text, H1–H3, bullet/ordered lists, quote, code block) and accepts custom items + group overrides.

Install

npx typix ui add slash-command

The CLI also installs @typix-editor/extension-slash-command if needed.

Import

import {
  SlashDropdownMenu,
  useSlashDropdownMenu,
} from "@/components/typix/main/slash-command";

Props

PropTypeDefaultDescription
configSlashMenuConfigEnabled items, groups, and custom items.
classNamestringExtra class on the dropdown container.
disabledbooleanfalseDisable the menu.
onSelect(item: SlashMenuItem) => voidCalled when an item is picked.
onOpen() => voidCalled when the menu opens.
onClose() => voidCalled when the menu closes.
emptyContentReactNodeShown when no items match the query.

SlashMenuConfig

FieldTypeDescription
enabledItemsSlashMenuItemType[]Which built-ins to show. Defaults to all.
customItemsSlashMenuItem[]Extra items to append.
itemGroupsRecord<string, string>Override the group label per item type.
showGroupsbooleanShow group headings. Default true.

SlashMenuItem

interface SlashMenuItem {
  type: SlashMenuItemType | string;
  title: string;
  subtext?: string;
  aliases?: string[];
  badge?: ComponentType<{ className?: string; size?: number }>;
  group?: string;
  onSelect: (ctx: { editor: LexicalEditor }) => void;
}

Usage

import { ImageIcon } from "lucide-react";
import { $createParagraphNode } from "lexical";
import { SlashDropdownMenu } from "@/components/typix/main/slash-command";

<SlashDropdownMenu
  config={{
    enabledItems: ["text", "heading_1", "heading_2", "bullet_list", "code_block"],
    customItems: [
      {
        type: "image",
        title: "Image",
        subtext: "Insert an image from your device",
        badge: ImageIcon,
        group: "Media",
        onSelect: ({ editor }) => openImagePicker(editor),
      },
    ],
  }}
/>

Hook

useSlashDropdownMenu gives you the raw item list — useful for embedding the items in a custom UI (e.g. a sidebar command palette):

const { getSlashMenuItems, getSuggestionItems } = useSlashDropdownMenu({
  customItems: [...],
});

On this page