A customizable dialog with HTML body and action buttons
Click the button below to see a simple dialog with default settings.
A common use case: confirming a destructive action with styled buttons.
Ask users if they want to save changes before leaving, with three options.
Dialogs support rich HTML content including lists, formatting, and more.
When content is long, the body becomes scrollable while buttons remain sticky at the bottom.
Modal dialogs dim the background and prevent interaction outside. Non-modal dialogs allow clicking outside.
Control whether Esc key and clicking outside can close the dialog.
Different button configurations: no buttons, one button, two buttons, or multiple buttons.
Multiple dialogs can be opened at the same time and will stack on top of each other.
Buttons can have custom background colors to match your design system.
Control how the dialog appears on screen with different animation effects.
You can include forms and interactive elements in the dialog body.
// Import the dialogAdd function
import { dialogAdd } from '@liwe3/webcomponents';
// Show a dialog
const dialog = dialogAdd({
title: 'Delete File',
body: '<p>Are you sure you want to delete this file?</p><p>This action cannot be undone.</p>',
buttons: [
{
label: 'Delete',
backgroundColor: '#dc3545',
onclick: () => {
console.log('File deleted');
dialog.close(); // Close the dialog after action
}
},
{
label: 'Cancel',
onclick: () => {
console.log('Cancelled');
dialog.close();
}
}
],
// Note: When custom buttons are provided, the default "Close" button is not shown
modal: true, // Dim background (default: true)
escToClose: true, // Allow Esc key to close (default: true)
clickToClose: true, // Allow clicking outside to close (default: true)
fxAppear: 'fade', // Animation: 'none', 'fade', or 'slide' (default: 'none')
onClose: () => console.log('Dialog closed')
});