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 support the same icon libraries as other UI elements:
  • PrimeVue icons: pi pi-[icon-name] (e.g., pi pi-star)
  • Material Design icons: mdi mdi-[icon-name] (e.g., mdi mdi-content-copy)

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