jQuery UI Library Dialog Creating a Dialog with Tabbed Titlebar


Occasionally, we may want to display dialogs with more than one pane of content. jQuery UI offers tabs that can be used in tandem with a dialog to make this possible. While it may be more common to have tabs within a dialog's content container, this example will demonstrate how to make a list of tabs the titlebar of the dialog.


<button id="openButton">
  Open Dialog
<div id="dialog" style="display:none">
  <div class="ui-tabs">
      <li><a href="#tab_1">Tab 1</a></li>
      <li><a href="#tab_2">Tab 2</a></li>
    <div id="tab_1">
      <p>Tab 1 content...</p>
    <div id="tab_2">
      <p>Tab 2 content...</p>


$(document).ready(function() {
  // Options to pass to the jQuery UI Dialog
  var options = {
    position: {
      my: "left top",
      at: "left top",
      of: window
    autoOpen: false

  /* Initialization */
  // Initialize the dialog
  var dialog = $("#dialog").dialog(options);

  // Initialize the tabs
  var tabs = $(".ui-tabs").tabs();

  /* Gather Elements Before Rearrangement */
  var closeButton = dialog.siblings(".ui-dialog-titlebar").find(".ui-dialog-titlebar-close");
  var initialTitlebar = dialog.siblings(".ui-dialog-titlebar");
  // Find the list of tabs to make the titlebar, add the ui-dialog-titlebar class, and append the close button
  var tabbedTitlebar = dialog.find(".ui-tabs ul:first").addClass("ui-dialog-titlebar").append(closeButton);

  /* Arranging */
  // Remove the initialTitlebar

  // Create a new .ui-tabs container for the tabbedTitlebar
  var tabbedTitlebarContainer = $("<div>", {
    class: "ui-tabs"

  // Prepend the tabbedTitlebarContainer to the dialog container

  /* Show the Dialog */

  var openButton = $("#openButton").button().click(function() {

Working example for reference: https://jsfiddle.net/5x4zz681/