Basic Usage
To add commands to the selection toolbox, your extension needs to:- Define commands with the standard command interface
- Implement the
getSelectionToolboxCommandsmethod to specify which commands appear in the toolbox
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: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 formicon-[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
ThegetSelectionToolboxCommands 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. TheselectedItems 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
commandsarray before being referenced ingetSelectionToolboxCommands - The toolbox automatically updates when the selection changes
- The
getSelectionToolboxCommandsmethod 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_nodesstill exists but only contains nodes