Add class to Select2 control

Add class to Select2 control

icefieldicefield Posts: 45Questions: 19Answers: 1

How would I go about adding an additional css style to a Select2 field? I'm trying to increase the number of displayed items in the Select2 dropdown, and apparently that is achieved by using the max-height style attribute.

Tried using the Select2 attr option (see, but couldn't get that to work.

Any guidance or examples appreciated.

This question has an accepted answers - jump to answer


  • icefieldicefield Posts: 45Questions: 19Answers: 1

    Well, dug a bit deeper and got something working. Here's what I did in case others need similar starting point:

    1) There is a dropdownCssClass option that can be added to Select2 opts. This is used to add a css style that will control the size of the drop down box.

    2) dropdownCssClass is not supported within minimized Select2 JS. You have use full version: //

    3) Create a css class (I used 'bigdrop') as follows:

    /* Select2 drop down size */
    .bigdrop {
        max-height: 35em !important;
        height: 35em !important;
        overflow-y: auto;

    4) bigdrop sets the size of the dropdown container, but the results shown will not be resized to fit the enlarged container. Add the following css to get the Select2 search results to fill the enlarged container:

    .select2-container--bootstrap4 .select2-results>.select2-results__options {
          max-height: 32em !important;
          overflow-y: auto !important;
  • colincolin Posts: 12,978Questions: 0Answers: 2,209
    Answer ✓

    Thanks for posting back,


Sign In or Register to comment.