Set height of select2

16,669

Solution 1

Try to use:

.select2-results__options {
   max-height: 500px;
}

If that doesn't work try to add !important so it overwrite it's default max-height (try both methods, yours and mine).

Solution 2

None of the answers above worked for me, but this did. I'm putting it here for future reference on google :

.select2-container--default .select2-results > .select2-results__options {
    max-height: 400px;
    min-height: 400px;
    overflow-y: auto;
}
Share:
16,669
D.R.
Author by

D.R.

https://www.rauch.io/

Updated on June 25, 2022

Comments

  • D.R.
    D.R. about 2 years

    How to increase the height of the select2 suggestion dropdown?

    I tried the idea proposed at https://github.com/select2/select2/issues/144:

    .select2-results {
      max-height: 500px;
    }
    

    However, that does not work. If I instead set the min-height property, the size is increased, however, I do not want to have a 500px huge dropdown if there are only 1 or 2 items...so min-height is not really an option.

    I want the dropdown to dynamically adjust its height to the content, but increase its height up to 500px before a scrollbar is displayed.