How to display multiple options visible ( ie size=15 )


In desktop browsers you can set the size and the height to display multiple options without having a dropdown, for example:

one two and so on

And all of the options will be visible in a box as a list without having to click on any drop-down.

How can I achieve this with Select2? Mobile browsers will not display multiple options visible like desktop browsers do. I am needing this functionality on both desktop and mobile. Can I do this with Select2?


You can programmatically force the Select2 open after you initialize it. Note that I’ve found you need a slight delay between when you initialize it and when you force it open. Something like this should work:

const $mySelect = $('#my-select');
$mySelect.select2({ /* config options here */ });
setTimeout(() => $mySelect.select2('open'), 500);