HTML CSS Bootstrap JavaScript jQuery MySQL PHP Data Mining

jQuery UI Widgets

Written by RedoHub Team · Last updated: August 1, 2026

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.


1. The Datepicker (Calendar)

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

2. The Accordion

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

3. Tabs

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
    });
});
Common Structure: Most jQuery UI widgets require a specific HTML structure (e.g., specific ID tags or list structures) to function correctly. Always consult the official documentation for the required markup.

Configuration via Options

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
Pro Tip: You can change options after a widget is initialized using the option method:
$("#slider").slider("option", "max", 500);

Key Points to Remember

  • Widgets are interactive UI components built on jQuery.
  • They require initialization (e.g., `.datepicker()`).
  • Custom behavior is achieved by passing an object { } to the widget function.
  • Most widgets have built-in events like `change`, `select`, or `open`.
  • Using widgets ensures a consistent user experience across your entire application.

Common Mistakes to Avoid

Forgetting to load the jQuery UI CSS theme. Widgets like the Datepicker and Accordion are functional without the theme stylesheet, but they render unstyled — always include a jQuery UI theme (e.g. Smoothness) alongside the script.
Loading jQuery UI before jQuery itself. jQuery UI is a plugin that extends jQuery — its script tag must come after the core jQuery script tag, or every widget call throws an error.
Re-initializing a widget on an element that already has one. Calling .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.

Try It: A Basic Slider Widget

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>

Frequently Asked Questions

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.