6

I want to customize the icons for the accordion. I found the page here http://jqueryui.com/accordion/#custom-icons But it seems to give a name of something there for the header and activeHeader.

How do you do this, if you just have a path to an image file?

apaul
  • 16,092
  • 8
  • 47
  • 82
sneaky
  • 2,141
  • 9
  • 31
  • 38

3 Answers3

34

Here's another option should you need the standard icons for another part of your project:

Working Example

JS

 $(function () {
     var icons = {
         header: "iconClosed",    // custom icon class
         activeHeader: "iconOpen" // custom icon class
     };
     $("#accordion").accordion({
         icons: icons
     });
 });

CSS

.ui-icon.iconOpen {
    background:url('YOUR Image HERE') no-repeat;
    background-size:20px;
    width:20px;
    height:20px;
}
.ui-icon.iconClosed {
    background:url('YOUR Image HERE') no-repeat -5px;
    background-size:30px;
    width:20px;
    height:20px;
}
apaul
  • 16,092
  • 8
  • 47
  • 82
4

You would need to write some custom CSS to replace the jQuery UI icon that you plan to use. For example, in the case of the example code:

ui-icon-circle-arrow-e {background-image:url('path/to/my/images/filename.png') !important;}

Very similar to this SO question

Community
  • 1
  • 1
DevlshOne
  • 8,357
  • 1
  • 29
  • 37
-1
$("#accordion").accordion({
  accordion: true,
  speed: 500,
  closedSign: '<img src="../../images/arrow-forward.png"/>',
  openedSign: '<img src="../../images/arrow-down.png"/>'
}); 
Limon Monte
  • 52,539
  • 45
  • 182
  • 213
abc
  • 1