Skip to content

Added an example for custom command + menu in the top bar #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions custom-nodes/javascript_examples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,34 @@ async nodeCreated(node) {
}
}
```

## Customizing the UI

### Add a custom menu in the top bar

You can add `commands` to your extension and add them to the top bar menu using `menuCommands`
- [MenuCommandGroup definition](https://github.com/Comfy-Org/ComfyUI_frontend/blob/main/src/types/comfy.ts)
- [ComfyCommand definition](https://github.com/Comfy-Org/ComfyUI_frontend/blob/main/src/stores/commandStore.ts)

```javascript
import { api } from "../../scripts/api.js";

app.registerExtension({
name: "example.extension.commands",
commands: [ // list of ComfyCommand
{
id: "my.custom.command", // command id
label: "My Custom Command",
function: () => {
console.log("executed custom command")
},
},
],
menuCommands: [ // list of MenuCommandGroup
{
path: ["Custom", "Commands"],
commands: ["my.custom.command"], // list of command ids
},
],
})
```