Can I set a Custom Icon for a jQueryUI Button

Boycs picture Boycs · May 14, 2010 · Viewed 8.5k times · Source

Is it possible to create a jQueryUI Button with a custom icon, ie: an icon that is not part of the sprite icons that are provided with jQueryUI???

I am using the ButtonSet functionality for a group of 3 checkboxes but need a more stylised icon than what is provided out of the box...

Answer

Boycs picture Boycs · May 14, 2010

Worked it out with a CSS hack.

Setup the button as per normal and give the primary icon the "Error" class defined below

.Error
{
    background-image: url('Images/Icons/16/Error.png') !important;
}

The !important overrides the ui-icon definition for background-image.