Javascript

jQuery UI Dialog - missing close icon

27 September 2026 · 9 min read

jQuery UI Dialog - missing close icon

The jQuery UI Dialog is a powerful tool for creating interactive modal windows within web applications. However, developers sometimes encounter a frustrating issue: the missing close icon. This can significantly impact user experience, making it difficult for users to dismiss the dialog box. Understanding the common causes behind this problem, such as CSS conflicts, incorrect jQuery UI versions, or improper initialization, is crucial for effective troubleshooting. A missing close icon can lead to user frustration and a perception of a broken interface. Correcting this issue promptly ensures that your web application remains user-friendly and professional, maintaining a seamless interaction for your visitors.

Common Causes of a Missing Close Icon

Several factors can contribute to the disappearance of the close icon in a jQuery UI Dialog. One of the most frequent culprits is CSS conflicts. Custom stylesheets or conflicting CSS rules from third-party libraries can override the default styling of the jQuery UI Dialog, effectively hiding or removing the close icon. Inspecting the element in your browser’s developer tools can reveal if any CSS rules are interfering with the icon’s display. Another common reason is the use of an outdated or incompatible version of jQuery UI. Ensure you’re using a version that’s compatible with your jQuery version and that all necessary CSS and JavaScript files are correctly linked in your HTML.

Furthermore, incorrect initialization of the jQuery UI Dialog can also lead to the missing close icon. If the closeText option is set to an empty string or a non-displaying character, or if the closeOnEscape option is disabled without providing an alternative close mechanism, the icon may appear to be missing. Double-check your JavaScript code to ensure that the Dialog is being initialized correctly and that all relevant options are configured as intended. Another potential issue is that custom themes can sometimes inadvertently remove the close button styles.

According to a Stack Overflow survey, over 30% of jQuery UI related questions involve styling or display issues, highlighting the frequency of CSS-related problems in web development. Ensuring you’re using up-to-date libraries and carefully managing your CSS can help avoid these common pitfalls. Properly configuring the jQuery UI Dialog options is also critical for a smooth user experience. For instance, if you are using a customized theme, verify the theme has the CSS necessary for the close button to appear.

Troubleshooting Steps: Identifying the Root Cause

To effectively address the missing close icon issue, a systematic troubleshooting approach is essential. Start by inspecting the Dialog element using your browser’s developer tools. This will allow you to examine the applied CSS rules and identify any conflicting styles that might be hiding the icon. Look for rules that set display: none, visibility: hidden, or manipulate the icon’s position or size. Next, verify that you are using compatible versions of jQuery and jQuery UI. Check the official jQuery UI documentation for compatibility information and ensure that you have included all required CSS and JavaScript files in your HTML. You can find version compatibility information at jQuery UI’s official website.

The following paragraph is optimized as a featured snippet:

Examine your JavaScript code to ensure that the jQuery UI Dialog is being initialized correctly. Pay close attention to the closeText option, ensuring that it is not set to an empty string. Also, check the closeOnEscape option to see if it’s enabled. If you are using a custom theme, make sure it includes the necessary CSS rules for displaying the close icon. Sometimes, custom themes may inadvertently override the default styles. If you suspect a theme issue, try using the default jQuery UI theme to see if the icon reappears.

Here are some troubleshooting steps:

  1. Inspect the element with browser developer tools.
  2. Check for CSS conflicts.
  3. Verify jQuery and jQuery UI versions.
  4. Examine JavaScript initialization code.
  5. Test with the default jQuery UI theme.

Solutions: Restoring the Close Icon

Once you’ve identified the cause, implementing the appropriate solution is crucial. If CSS conflicts are the culprit, you can override the conflicting styles by adding specific CSS rules to your stylesheet. Use the !important declaration to ensure that your rules take precedence. For example, you might add the following CSS to ensure the close icon is visible: .ui-dialog-titlebar-close { display: block !important; }. If you’re using an older version of jQuery UI, consider updating to the latest version. This often resolves compatibility issues and includes bug fixes that may address the missing icon problem.

If the issue stems from incorrect initialization, modify your JavaScript code to properly configure the closeText and closeOnEscape options. Ensure that closeText is set to a non-empty string and that closeOnEscape is enabled or that an alternative close mechanism is provided. For instance, you can add a custom close button within the Dialog’s content. You can find examples of custom close buttons on sites like Stack Overflow.

If a custom theme is causing the problem, either modify the theme to include the necessary CSS for the close icon or switch to the default jQuery UI theme. Modifying a theme involves locating the relevant CSS rules and ensuring they are properly defined. If you choose to switch to the default theme, simply remove the link to your custom theme stylesheet and include the default jQuery UI theme stylesheet instead. Remember to thoroughly test your solution to ensure that the close icon is consistently displayed across different browsers and devices.

Preventative Measures and Best Practices

To minimize the risk of encountering the missing close icon issue in the future, adopt preventative measures and follow best practices. Prioritize using compatible versions of jQuery and jQuery UI and keep your libraries up to date. This ensures that you benefit from the latest bug fixes and security patches. Implement a well-organized CSS architecture to avoid conflicts. Use CSS naming conventions and scoping techniques to prevent styles from unintentionally affecting other elements on your page. Tools like BEM (Block, Element, Modifier) can help with this.

Always thoroughly test your jQuery UI Dialogs in different browsers and devices. This helps identify potential compatibility issues early on. Use a browser testing tool to automate the process. Regularly review your code and CSS to identify and address any potential problems. This proactive approach can prevent minor issues from escalating into major headaches. Also, consider using a linter or code quality tool to enforce coding standards and identify potential errors. You can use tools like ESLint to help keep your code clean and consistent.

  • Keep jQuery and jQuery UI updated.
  • Use a consistent CSS architecture.

Consider using a modular approach to CSS, where styles are scoped to specific components. This reduces the likelihood of conflicts and makes it easier to maintain your stylesheets. Also, make sure your Dialog is accessible. Accessible Rich Internet Applications (ARIA) attributes can be used to improve the accessibility of your Dialogs.

Infographic showing common causes and solutions for missing jQuery UI Dialog close icon.
Here are some key points to consider for best practices:
  • Test across multiple browsers and devices.
  • Regularly review code for potential issues.

FAQ: jQuery UI Dialog - Missing Close Icon

Why is my jQuery UI Dialog close icon missing?
This is often due to CSS conflicts, incorrect jQuery UI versions, or improper initialization. Check your CSS for conflicting rules, ensure your jQuery and jQuery UI versions are compatible, and verify the Dialog's initialization code.
How do I check for CSS conflicts?
Use your browser's developer tools to inspect the Dialog element and examine the applied CSS rules. Look for rules that set display: none, visibility: hidden, or manipulate the icon's position.
What should I do if my jQuery UI version is outdated?
Update to the latest version of jQuery UI. This often resolves compatibility issues and includes bug fixes that may address the missing icon problem. Check the [jQuery UI download page](https://jqueryui.com/download/) for the latest version.
How do I properly initialize the jQuery UI Dialog?
Ensure that the closeText option is not set to an empty string and that closeOnEscape is enabled or that an alternative close mechanism is provided.
Addressing a missing close icon in your jQuery UI Dialog doesn't have to be a major hurdle. By systematically troubleshooting, understanding common causes, and implementing the appropriate solutions, you can quickly restore this essential UI element. Remember to prioritize preventative measures and best practices to avoid similar issues in the future. This ensures a smoother development process and a better user experience.

Don’t let a missing close icon hinder your web application’s usability. Take the steps outlined in this article to diagnose and fix the problem. And if you’re looking to further enhance your web development skills, explore more resources on jQuery UI and advanced CSS techniques. Check out this helpful guide to enhance your coding skills.

Question & Answer :
I’m using a custom jQuery 1.10.3 theme. I downloaded every straight from the theme roller and I have intentionally not changed anything.

I created a dialog box and I get an empty gray square where the close icon should be: Screen shot of missing close icon

I compared the code that is generated on my page:

<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"> <spanid="ui-id-2" class="ui-dialog-title">Title</span> <button class="ui-dialog-titlebar-close"></button> </div> 

To the code generated on the Dialog Demo page:

<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"> <span id="ui-id-1" class="ui-dialog-title">Basic dialog</span> <button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only ui-dialog-titlebar-close" role="button" aria-disabled="false" title="close"> <span class="ui-button-icon-primary ui-icon ui-icon-closethick"></span> <span class="ui-button-text">close</span> </button> </div> 

EDIT

The different parts of the code are generated by jQueryUI, not me so I can’t just add the span tags without editing the jqueryui js file which seems like a bad/unnecessary choice to achieve normal functionality.

Here is the JavaScript used that generates that part of the code:

this.element.dialog({ appendTo: "#summary_container", title: this.title(), closeText: "Close", width: this.width, position: { my: "center top", at: ("center top+"+(window.innerHeight*.1)), collision: "none" }, modal: false, resizable: false, draggable: false, show: "fold", hide: "fold", close: function(){ if(KOVM.areaSummary.isVisible()){ KOVM.areaSummary.isVisible(false); } } }); 

I’m at a loss and need help.

I am late to this one by a while, but I’m going to blow your mind, ready?

The reason this is happening, is because you are calling bootstrap in, after you are calling jquery-ui in.

Literally, swap the two so that instead of:

<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> <script src="js/bootstrap.min.js"></script> 

it becomes

<script src="js/bootstrap.min.js"></script> <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 

:)

Edit - 26/06/2015 - this keeps attracting interest months later so I thought it was worth an edit. I actually really like the noConflict solution offered in the comment underneath this answer and clarified by user Pretty Cool as a separate answer. As some have reported issues with the bootstrap tooltip when the scripts are swapped. I didn’t experience that issue however because I downloaded jquery UI without the tooltip as I didn’t need it because bootstrap. So this issue never came up for me.

Edit - 22/07/2015 - Don’t confuse jquery-ui with jquery! While Bootstrap’s JavaScript requires jQuery to be loaded before, it doesn’t rely on jQuery-UI. So jquery-ui.js can be loaded after bootstrap.min.js, while jquery.js always needs to be loaded before Bootstrap.