XUL ( ), which stands for XML User Interface Language, is a user interface markup language developed by Mozilla. XUL is an XML dialect for writing graphical user interfaces, enabling developers to write user interface elements in a manner similar to web pages.
XUL applications rely on the Mozilla codebase or a fork of it. The most prominent example is the Firefox web browser. However, Mozilla has significantly reduced the usage of XUL in Firefox after their rewrite of the browser engine in version 57. This resulted in the removal of the legacy add-on system, which relied on XUL and XPCOM, another cross-platform technology Mozilla decided to deprecate shortly before the release of Firefox 57. Firefox originally permitted add-ons to extensively alter its user interface, but this capability was removed in 2017 and replaced with the less-permissive WebExtensions API. Several forks of Firefox retain support for XUL and XPCOM-based add-ons. Waterfox maintains a fork of the legacy Mozilla codebase for the Waterfox Classic browser. The Pale Moon browser, Basilisk browser, and numerous smaller projects collectively use and maintain the Unified XUL Platform (UXP) implementation.
History
thumb|The Periodic Table of XUL Elements is a reference extension designed to demonstrate XUL's capabilities.
XUL was devised at Netscape in 1997 as part of the development effort that eventually became the Mozilla codebase. XUL is similar to web technologies implemented by the Gecko rendering engine. When XUL was introduced, it added features beyond the then standard HTML 4. It was designed as an extension of HTML to be used with applications rather than documents.
XUL was used by various Mozilla projects, forks of Mozilla projects, and projects closely related to Mozilla. Some software projects such as Songbird, Komodo IDE, and Zotero started as desktop applications that utilized XULRunner to render and compose their UI. In the early 2000s, there was some interest in using XUL by other parties, including Amazon, but those have switched over to HTML5.
The SeaMonkey internet suite chose to re-implement XUL for the Firefox Quantum codebase, and the suite's development has subsequently slowed. The Pale Moon developers forked Mozilla's entire Firefox 52 ESR codebase to create the Unified XUL Platform (UXP) for their Goanna rendering engine. UXP maintains the traditional XUL capabilities. As a result, Pale Moon and other UXP applications are more extensible compared to modern versions of Firefox and Thunderbird.
Usage
XUL can only be used with the Mozilla codebase (or a fork of it) because the Gecko (or Goanna) engine does the XUL rendering.
Application programmers need to define a XUL interface as three discrete sets of components:
- Content: the XUL document(s), whose elements define the layout of the user interface
- Skin: the CSS and image files, which define the appearance of an application
- Locale: the files containing user-visible strings for easy software localization
XUL defines a wide range of elements, which roughly belong to the following types:
- Top-level elements: window, page, dialog, wizard, etc.
- Widgets: label, button, text box, list box, combo box, radio button, check box, tree, menu, toolbar, group box, tab box, color-picker, spacer, splitter, etc.
- Box model: box, grid, stack, deck, etc.
- Events and scripts: script, command, key, broadcaster, observer, etc.
- Data source: template, rule, etc.
- Others: overlay, iframe, browser, editor, etc.
The default behavior of XUL widgets can be altered with XBL bindings.
XBL
XML Binding Language (XBL) is an XML-based markup language for altering the behavior of a XUL widget, such as a scroll bar. An XBL file contains bindings, each of which describes the behavior of a XUL widget. The root element of an XBL file is the <code><nowiki><bindings></nowiki></code> element, which contains one or more <code><nowiki><binding></nowiki></code> elements. Each <code><nowiki><binding></nowiki></code> element declares one binding, which can be attached to any XUL element. It may also possess an <code><nowiki>id</nowiki></code> attribute. A binding is assigned to an element by setting the CSS property <code><nowiki>-moz-binding</nowiki></code> to the URL of the binding's file. For example:
<syntaxhighlight lang="css">
scrollbar {
-moz-binding: url('somefile.xml#binding1');
}
</syntaxhighlight>
Example
This example shows three buttons stacked on top of each other in a vertical box container:
right
<syntaxhighlight lang="xul+mozpreproc">
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="vbox example" title="Example 3...."
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<layout>
<button id="yes1" label="Yes"/>
<button id="no1" label="No"/>
<button id="maybe1" label="Maybe"/>
</layout>
</window>
</syntaxhighlight>
Ghostbusters reference
XUL contains a reference to the 1984 film Ghostbusters. Zuul possesses the character Dana Barrett and declares: "There is no Dana. There is only Zuul." made the slogan, "There is no data. There is only XUL!". The slogan and Zuul as a gatekeeper are referenced in XUL's XML namespace URI and were previously present in all Firefox add-ons:
