Easy Tutorial
❮ Example Selectable Api Fade Effect ❯

jQuery UI API - Dialog Widget

Category

Widgets

Usage

Description: Opens content in an interactive overlay.

Version Added: 1.0

A dialog is a floating window that includes a title bar and a content area. The dialog window can be moved, resized, and closed with the 'x' icon by default.

If the content length exceeds the maximum height, a scrollbar will automatically appear.

A bottom button bar and a semi-transparent modal overlay are common additions.

Focus

When a dialog is opened, focus is automatically moved to the first item that meets the following conditions:

When opened, the Dialog Widget ensures that focus is cycled between elements within the dialog when tabbing, excluding elements outside the dialog. Modal dialogs prevent mouse users from clicking on elements outside the dialog.

When the dialog is closed, focus automatically returns to the element that had focus when the dialog was opened.

Hiding the Close Button

In some cases, you might want to hide the close button, for example, when a close button is already present in the button pane. The best approach is to use CSS. For instance, you can define a simple rule like:

.no-close .ui-dialog-titlebar-close {
  display: none;
}

Then, you can add the no-close class to any dialog to hide the close button:

$( "#dialog" ).dialog({
  dialogClass: "no-close",
  buttons: [
    {
      text: "OK",
      click: function() {
        $( this ).dialog( "close" );
      }
    }
  ]
});

Theming

The Dialog Widget uses the jQuery UI CSS Framework to define its visual styling. If you need to use specific styles for the dialog, you can use the following CSS class names:

Additionally, when the modal option is set, an element with the ui-widget-overlay class name is appended to the <body>.

Dependencies

Additional Notes

View Demo

❮ Example Selectable Api Fade Effect ❯