The Dialog API provides standardized dialogs that work consistently across desktop and web environments. Extension authors will find the prompt and confirm methods most useful.
Basic Usage
Prompt Dialog
// Show a prompt dialog
app.extensionManager.dialog.prompt({
title: "User Input",
message: "Please enter your name:",
defaultValue: "User"
}).then(result => {
if (result !== null) {
console.log(`Input: ${result}`);
}
});
Confirm Dialog
// Show a confirmation dialog
app.extensionManager.dialog.confirm({
title: "Confirm Action",
message: "Are you sure you want to continue?",
type: "default"
}).then(result => {
console.log(result ? "User confirmed" : "User cancelled");
});
API Reference
Prompt
app.extensionManager.dialog.prompt({
title: string, // Dialog title
message: string, // Message/question to display
defaultValue?: string // Initial value in the input field (optional)
}).then((result: string | null) => {
// result is the entered text, or null if cancelled
});
Confirm
app.extensionManager.dialog.confirm({
title: string, // Dialog title
message: string, // Message to display
type?: "default" | "overwrite" | "delete" | "dirtyClose" | "reinstall", // Dialog type (optional)
itemList?: string[], // List of items to display (optional)
hint?: string // Hint text to display (optional)
}).then((result: boolean | null) => {
// result is true if confirmed, false if denied, null if cancelled
});
For other specialized dialogs available in ComfyUI, extension authors can refer to the dialogService.ts
file in the source code.