Widgets are full-featured user interface components that have a specific behavior and visual style. They are designed to save you hundreds of hours of coding by providing ready-to-use, accessible elements like calendars, sliders, and collapsible panels.
This is arguably the most popular widget. It attaches an interactive calendar to a normal input field.
// Simple Initialization
$("#birthday").datepicker();
// Custom configuration
$("#appointment").datepicker({
showAnim: "slideDown",
numberOfMonths: 2,
dateFormat: "dd/mm/yy"
});
The Accordion widget turns a series of headers and content panels into a collapsible menu where only one section is open at a time.
$(function() {
$("#myAccordion").accordion({
collapsible: true,
active: false,
heightStyle: "content"
});
});
The Tabs widget allows you to organize large amounts of content into small, clickable sections.
$(function() {
$("#myTabs").tabs({
event: "mouseover" // Open tabs on hover instead of click
});
});
Every widget in jQuery UI can be customized by passing an options object during initialization. This allows you to change how it looks or behaves without editing the core library.
| Widget | Popular Options |
|---|---|
| Slider | min, max, value, range, step |
| Autocomplete | source, minLength, delay |
| Dialog | modal, buttons, resizable, title |
option method: $("#slider").slider("option", "max", 500);
.datepicker() twice on the same input can duplicate event bindings — check .data("ui-datepicker") or destroy the existing instance first if you need to reconfigure it.
A second example — a slider that updates a text field live as the user drags it:
<div id="volumeSlider"></div>
<p>Volume: <span id="volumeValue">50</span></p>
<script>
$(function() {
$("#volumeSlider").slider({
value: 50,
min: 0,
max: 100,
slide: function(event, ui) {
$("#volumeValue").text(ui.value);
}
});
});
</script>
Q: Is jQuery UI the same library as jQuery?
A: No — jQuery UI is a separate, official plugin built on top of jQuery that adds widgets, interactions (like drag-and-drop), and animation effects.
Q: Do I need every jQuery UI widget, or can I load just one?
A: You can build a custom download with only the widgets you need from the official jQuery UI download builder, which keeps your page lighter.
Q: Are jQuery UI widgets still maintained?
A: The project receives maintenance releases rather than new features — for brand-new UI components, many teams now reach for lighter, framework-specific libraries, but jQuery UI remains reliable for existing projects.