Here is a good introduction on how to build a widget with jQuery-UI
http://net.tutsplus.com/tutorials/javascript-ajax/coding-your-first-jquery-ui-plugin/
as well as
http://ajpiano.com/widgetfactory
They also list their references which directly links you to more tutorials and documentation on the matter.
The basics are that you will define a widget name
$.widget('ui.widget_name', {
options: {
overrideableOption: true,
},
_create: function () {
//fires when you first create the widget, and can be used as a callback for the 'create' event
},
_additional_events.....
});
then you can call your widget by using the naming convention after the ui
namespace
$(element).widget_name({overrideableOption: false});
Hope that can get you started.