Files
ComfyUI_frontend/src/assets/icons
Johnpaul Chiwetelu ac107b45ea Floating Selection Toolbox Improvements (#5218)
* WIP

* WIP: UI design for right click menu

* feat: add composable for node customization and information handling

* fix: correct v-show directive in MaskEditorButton and enhance MoreOptions functionality

* feat: add selection and subgraph operations composables for enhanced graph management

* fix: update computed properties to use 'void' for non-reactive calls and add MenuOptionItem component

* feat: add composables for More Options menu and submenu positioning logic

* feat: refactor MoreOptions component to use MenuOptionItem for menu rendering and streamline submenu handling

* feat: implement SubmenuPopover component for enhanced submenu functionality and selection handling

* feat: add 'More Options' label and enhance shape options in localization file

* refactor: simplify shape name handling by removing Pascal case conversion and using localized names

* refactor: enhance submenu handling by dynamically setting refs and improving key assignment

* feat: implement useNodeArrangement composable for node alignment and distribution functionality

* feat: enhance useMoreOptionsMenu with image node operations and alignment options

* feat: localize context menu options and enhance submenu handling

* refactor: improve type safety for title assignment in selection operations and enhance color option retrieval in node customization

* fix: adjust component order in SelectionToolbox for improved layout

* feat: update FrameNodes button visibility and tooltip, and add localization for frameNodes

* feat: enhance button visibility logic in SelectionToolbox based on selection types

* refactor: reorganize properties panel option in More Options menu for single nodes

* remove excessive logging and alerts

* fix component tests

* ad browser tests

* feat: enhance popover behavior in MoreOptions component to manage visibility state during selection overlay changes

* refactor: update visibility logic for buttons in SelectionToolbox and ExecuteButton components

* refactor: remove duplicate shape option and clean up shapeOptions array

* refactor: update help toggle logic in InfoButton and useMoreOptionsMenu to manage sidebar and help state

* refactor: streamline node info handling and integrate output node filtering in useNodeInfo and useMoreOptionsMenu

* Added useSelectionState composable consolidating all selection-derived state and the node help toggle

* Updated toolbox buttons (InfoButton, BookmarkButton, BypassButton, MaskEditorButton, ConvertToSubgraphButton, PinButton, DeleteButton, ColorPickerButton, ExecuteButton, FrameNodes, Load3DViewerButton) to remove duplicated selection logic and use useSelectionState

* Introduced HideReason ('manual' | 'drag') to differentiate drag-induced hides from manual/outside hides in MoreOptions

* refactor: enhance popover visibility handling during drag events using canvas state

* fix: update shape option name from 'default' to 'box' and add localization for 'box'

* refactor: streamline BypassButton logic and enhance MoreOptions menu with state bumping

* refactor: remove toast notifications from subgraph operations for cleaner logic

* refactor: ensure menu options re-compute when selection flags change

* feat: Enhance MoreOptions behavior with drag-and-drop support

* fix: Update mask icon class for consistent styling in MaskEditorButton

* refactor: Standardize icon sizes and classes across selection toolbox buttons

* refactor: Update layout and styling in SelectionToolbox and MoreOptions components

* refactor: Improve selection toolbox behavior with more options state management

* Refactor: Remove unused imports and conditionally add subgraph option in menu

* Enhance popover behavior: add show/hide event handlers and improve positioning logic

* Cleanup: Remove debug comments from popover functions for clarity

* Refactor: Clean up FrameNodes component and add MenuOptionBadge for better option display

* Cleanup: Remove debug comments from useSelectionToolboxPosition for clarity

* Add useFrameNodes composable for grouping selected nodes

* Refactor: Update shape options in useNodeCustomization and localize frame nodes label

* fix tests

* Cleanup: Remove packageManager entry from package.json

* Refactor: Replace ILucide icons with named imports from lucide-vue-next

* Refactor: Update shape selection and improve color picker behavior in selection toolbox

* Update test expectations [skip ci]

* feat: Enhance More Options Menu for group node management and update localization strings

* refactor: Comment out PublishButton

* refactor: Comment out test for bookmark button visibility in SelectionToolbox

* refactor: Update class names for dark theme compatibility in ExecuteButton and MenuOptionItem components

* refactor: Modularize menu options by creating dedicated composables for group, image, node, and selection operations

* refactor: Update selectors in tests to match design changes

* refactor: Update help button selector in Node Help tests

* refactor: Update getGroupColorOptions to accept groupContext and bump parameters

* Update test expectations [skip ci]

* refactor: Center KSampler node before interaction in More Options submenu tests

* refactor: Adjust KSampler node positioning and simplify button click in More Options submenu tests

* refactor: Rename comfyPageFixture import for clarity

* refactor: use gap-1 instead of the explicit gap-[4px]

* refactor: Replace app.canvas with canvasStore.getCanvas for  state management

* refactor: Simplify prop access by removing 'props.' prefix in MenuOptionItem component

* refactor: Remove explicit type annotation for item in buildSelectionSignature function

* refactor: Replace Lucide icons with string-based icon references in menu options

* refactor: Remove export from interface declarations for improved clarity

* refactor: Simplify class binding in BypassButton component for improved readability

* refactor: Update button class for consistent sizing in ExecuteButton component

* refactor: Update help button locator class for consistency in Node Help tests

* fix node help test

* refactor: Remove unused imports and simplify visibility conditions in selection toolbox components

* feat: Add 3D node selection logic and cleanup on unmount for selection toolbox

* refactor: Update help button locator to use consistent data-testid in Node Help tests

* fix: Correct help button locator syntax in Node Help tests

* refactor: Change resetMoreOptionsState to an internal function in useSelectionToolboxPosition

* test: Add Load3D node visibility logic for ColorPickerButton and remove redundant test case

* fix: Increase tooltip show delay for ColorPickerButton

* fix: Update selectedOutputNodes computation to filter by isLGraphNode

* fix: Remove unused nodeDef reference from InfoButton and submenu trigger from MenuOptionItem

* fix: Update showInfoButton logic to depend on nodeDef value

* refactor: Remove deprecated getBasicNodeOptions function for cleaner code

* refactor: Replace useNodeInfo with useSelectedNodeActions

* refactor: Integrate useNodeDefStore for improved node definition handling in SelectionToolbox and InfoButton tests

* refactor: Introduce useCanvasRefresh composable for consistent canvas refresh logic across node operations

* refactor: Remove irrelevant append-to attribute from Popover

* refactor: Use storeToRefs for selectedItems in useSelectionState and add tests for selection logic

* refactor: Update ExecuteButton to use hasOutputNodesSelected for visibility and remove unnecessary computed property

* refactor: move display of execution button tests to selectionToolbox

---------

Co-authored-by: github-actions <github-actions@github.com>
2025-09-13 22:52:30 -07:00
..

ComfyUI Icons Guide

ComfyUI supports three types of icons that can be used throughout the interface. All icons are automatically imported - no manual imports needed!

Quick Start - Code Examples

1. PrimeIcons

<template>
  <!-- Basic usage -->
  <i class="pi pi-plus" />
  <i class="pi pi-cog" />
  <i class="pi pi-check text-green-500" />

  <!-- In PrimeVue components -->
  <button icon="pi pi-save" label="Save" />
  <button icon="pi pi-times" severity="danger" />
</template>

Browse all PrimeIcons →

<template>
  <!-- Primary icon set: Lucide -->
  <i-lucide:download />
  <i-lucide:settings />
  <i-lucide:workflow class="text-2xl" />

  <!-- Other popular icon sets -->
  <i-mdi:folder-open />
  <!-- Material Design Icons -->
  <i-heroicons:document-text />
  <!-- Heroicons -->
  <i-tabler:brand-github />
  <!-- Tabler Icons -->
  <i-carbon:cloud-upload />
  <!-- Carbon Icons -->

  <!-- With styling -->
  <i-lucide:save class="w-6 h-6 text-blue-500" />
</template>

Browse 200,000+ icons →

3. Custom Icons

<template>
  <!-- Your custom SVG icons from src/assets/icons/custom/ -->
  <i-comfy:workflow />
  <i-comfy:node-tree />
  <i-comfy:my-custom-icon class="text-xl" />

  <!-- In PrimeVue button -->
  <Button severity="secondary">
    <template #icon>
      <i-comfy:workflow />
    </template>
  </Button>
</template>

Icon Usage Patterns

In Buttons

<template>
  <!-- PrimeIcon in button (simple) -->
  <Button icon="pi pi-check" label="Confirm" />

  <!-- Iconify/Custom in button (template) -->
  <Button>
    <template #icon>
      <i-lucide:save />
    </template>
    Save File
  </Button>
</template>

Conditional Icons

<template>
  <i-lucide:eye v-if="isVisible" />
  <i-lucide:eye-off v-else />

  <!-- Or with ternary -->
  <component :is="isLocked ? 'i-lucide:lock' : 'i-lucide:lock-open'" />
</template>

With Tooltips

<template>
  <i-lucide:info
    v-tooltip="'Click for more information'"
    class="cursor-pointer"
  />
</template>

Using Iconify Icons

Finding Icons

  1. Visit Iconify Icon Sets
  2. Search or browse collections
  3. Click on any icon to get its name
  4. Use with i-[collection]:[icon-name] format
  • Lucide (i-lucide:) - Our primary icon set, clean and consistent
  • Material Design Icons (i-mdi:) - Comprehensive Material Design icons
  • Heroicons (i-heroicons:) - Beautiful hand-crafted SVG icons
  • Tabler (i-tabler:) - 3000+ free SVG icons
  • Carbon (i-carbon:) - IBM's design system icons

Adding Custom Icons

1. Add Your SVG

Place your SVG file in src/assets/icons/custom/:

src/assets/icons/custom/
├── workflow-duplicate.svg
├── node-preview.svg
└── your-icon.svg

2. SVG Format Requirements

<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
  <!-- Use currentColor for theme compatibility -->
  <path fill="currentColor" d="..." />
</svg>

Important:

  • Use viewBox for proper scaling (24x24 is standard)
  • Don't include width or height attributes
  • Use currentColor for theme-aware icons
  • Keep SVGs optimized and simple

3. Use Immediately

<template>
  <i-comfy:your-icon />
</template>

No imports needed - icons are auto-discovered!

Icon Guidelines

Naming Conventions

  • Files: kebab-case.svg (workflow-icon.svg)
  • Usage: <i-comfy:workflow-icon />

Size & Styling

<template>
  <!-- Size with Tailwind classes -->
  <i-lucide:plus class="w-4 h-4" />
  <!-- 16px -->
  <i-lucide:plus class="w-6 h-6" />
  <!-- 24px (default) -->
  <i-lucide:plus class="w-8 h-8" />
  <!-- 32px -->

  <!-- Or text size -->
  <i-lucide:plus class="text-sm" />
  <i-lucide:plus class="text-2xl" />

  <!-- Colors -->
  <i-lucide:check class="text-green-500" />
  <i-lucide:x class="text-red-500" />
</template>

Theme Compatibility

Always use currentColor in SVGs for automatic theme adaptation:

<!-- ✅ Good: Adapts to light/dark theme -->
<svg viewBox="0 0 24 24">
  <path fill="currentColor" d="..." />
</svg>

<!-- ❌ Bad: Fixed colors -->
<svg viewBox="0 0 24 24">
  <path fill="#000000" d="..." />
</svg>

Migration Guide

From PrimeIcons to Iconify/Custom

<template>
  <!-- Before -->
  <Button icon="pi pi-download" />

  <!-- After -->
  <Button>
    <template #icon>
      <i-lucide:download />
    </template>
  </Button>
</template>

From Inline SVG to Custom Icon

<template>
  <!-- Before: Inline SVG -->
  <svg class="w-6 h-6" viewBox="0 0 24 24">
    <path d="..." />
  </svg>

  <!-- After: Save as custom/my-icon.svg and use -->
  <i-comfy:my-icon class="w-6 h-6" />
</template>

Technical Details

Auto-Import System

Icons are automatically imported using unplugin-icons - no manual imports needed! Just use the icon component directly.

Configuration

The icon system has two layers:

  1. Build-time Processing (build/customIconCollection.ts):

    • Scans src/assets/icons/custom/ for SVG files
    • Validates SVG content and structure
    • Creates Iconify collection for Tailwind CSS
    • Provides error handling for malformed files
  2. Vite Runtime (vite.config.mts):

    • Enables direct SVG import as Vue components
    • Supports dynamic icon loading
// Build script creates Iconify collection
export const iconCollection: IconifyCollection = {
  prefix: 'comfy',
  icons: {
    'workflow': { body: '<svg>...</svg>' },
    'node': { body: '<svg>...</svg>' }
  }
}

// Vite configuration for component-based usage
Icons({
  compiler: 'vue3',
  customCollections: {
    comfy: FileSystemIconLoader('src/assets/icons/custom')
  }
})

TypeScript Support

Icons are fully typed. If TypeScript doesn't recognize a new custom icon:

  1. Restart the dev server
  2. Ensure the SVG file is valid
  3. Check filename follows kebab-case

Troubleshooting

Icon Not Showing

  1. Check filename: Must be kebab-case without special characters
  2. Restart dev server: Required after adding new icons
  3. Verify SVG: Ensure it's valid SVG syntax (build script validates automatically)
  4. Check console: Look for Vue component resolution errors
  5. Build script errors: Check console during build - malformed SVGs are logged but don't break builds

Icon Wrong Color

  • Replace hardcoded colors with currentColor
  • Use stroke="currentColor" for outlines
  • Use fill="currentColor" for filled shapes

Icon Wrong Size

  • Remove width and height from SVG
  • Ensure viewBox is present
  • Use CSS classes for sizing: class="w-6 h-6"

Best Practices

  1. Optimize SVGs: Use tools like SVGO to minimize file size
  2. Consistent viewBox: Stick to 24x24 or 16x16 for consistency
  3. Semantic names: Use descriptive names like workflow-duplicate not icon1
  4. Theme support: Always use currentColor for adaptable icons
  5. Test both themes: Verify icons look good in light and dark modes

Adding Icon Collections

To add an entire icon set from npm:

  1. Install the icon package
  2. Configure in vite.config.mts
  3. Use with the appropriate prefix

See the unplugin-icons documentation for details.

Resources