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);