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
To learn more about the widget factory, visit learn.jquery.com.