This demo shows a simple custom widget built using the widget factory (jquery.ui.widget.js).
The three boxes are initialized in different ways. Clicking them changes their background color. View source to see how it works, its heavily commented
For more details on the widget factory, visit the jQuery UI planning wiki.