Overview
You can create Vue-based widgets using thegetCustomVueWidgets() hook. ComfyUI exposes Vue globally as window.Vue, so your extension uses the same Vue instance as the main app (smaller bundle size).
Project Structure
Complete Example
package.json
vite.config.ts
extension.js
WidgetStarRating.vue
init.py
Using Tailwind CSS
tailwind.config.js
postcss.config.js
styles.css
Handling Positioning
Without Tailwind’s preflight, some utility classes likeabsolute, translate-x-1/2 may not work as expected. Use inline styles for critical positioning:
Widget Component API
Your Vue component receives these props:
Use
defineModel() for two-way value binding:
Build and Test
Development Workflow
Run the watcher during development:dist/extension.js on every file change. Refresh ComfyUI to see updates.
Common Pitfalls
Failed to resolve module specifier “vue”
The browser can’t resolve bare"vue" imports.
Solution: Use rollup-plugin-external-globals to map Vue imports to window.Vue:
CSS Not Loading
ComfyUI only loads JS files. CSS must be inlined into the bundle. Solution: Usevite-plugin-css-injected-by-js.
Styles Affecting Other UI
Tailwind’s preflight resets global styles, breaking ComfyUI. Solution: Setpreflight: false in tailwind.config.js.
Accessing ComfyUI’s App
Import from the relative path toscripts/app.js:
Examples
- ComfyUI_vue_widget_example - Minimal example with star rating widget (source for this documentation)
- ComfyUI_frontend_vue_basic - Full Vue extension with PrimeVue, i18n, drawing board widget