Skip to main content
The Selection Toolbox API allows extensions to add custom action buttons that appear when nodes are selected on the canvas. This provides quick access to context-sensitive commands for selected items (nodes, groups, etc.).

Basic Usage

To add commands to the selection toolbox, your extension needs to:
  1. Define commands with the standard command interface
  2. Implement the getSelectionToolboxCommands method to specify which commands appear in the toolbox
Note: The getSelectionToolboxCommands method is called for each item in the selection set whenever a new selection is made.

Command Definition

Commands for the selection toolbox use the standard ComfyUI command interface:
The function receives the selected item(s) as a parameter, allowing you to perform actions on the current selection.

Icon Options

Selection toolbox buttons use Lucide icon classes in the form icon-[lucide--<icon-name>] (e.g., icon-[lucide--star]). The frontend generates these classes when it is built, so only the Lucide icons that the frontend itself uses are available. If an icon does not render, pick another icon, or define your own icon class in a stylesheet that your extension loads. PrimeIcons (pi pi-*) and Material Design Icons (mdi mdi-*) classes still render for now, but they are being phased out. Don’t use them in new code. See PrimeVue removal migration.

Dynamic Command Visibility

The getSelectionToolboxCommands method is called each time the selection changes, allowing you to show different commands based on what’s selected:

Working with Selected Items

Access information about selected items through the app’s canvas object. The selectedItems property is a Set that includes nodes, groups, and other canvas elements:

Complete Example

Here’s a simple example showing various selection toolbox features:

Notes

  • The selection toolbox must be enabled in settings: Comfy.Canvas.SelectionToolbox
  • Commands must be defined in the commands array before being referenced in getSelectionToolboxCommands
  • The toolbox automatically updates when the selection changes
  • The getSelectionToolboxCommands method is called for each item in the selection set whenever a new selection is made
  • Use app.canvas.selectedItems (a Set) to access all selected items including nodes, groups, and other canvas elements
  • For backward compatibility, app.canvas.selected_nodes still exists but only contains nodes