With a HTML <select>
in multiple
mode, how to enable the selection of multiple items with a touchscreen device?
-
Drag/drop or swipe cannot be used for selection, it is already used to scroll the scrollbar of the list
-
Click / tap cannot be used because this is used to select a new single item (see the UX in Windows File Explorer or Mac Finder)
-
Double-click / double-tap is already used to open the selected element (e.g. like in a file explorer)
Is there a built-in HTML5 way to do this?
select { width: 10em; height: 12em; }
<select multiple>
<option>Dog</option>
<option>Cat</option>
<option>Hamster</option>
<option>Parrot</option>
<option>Spider</option>
<option>Goldfish</option>
<option>Elephant</option>
<option>Mouse</option>
<option>Bee</option>
<option>Sheep</option>
<option>Fox</option>
</select>
Note: this is how it is displayed by default on Android, but I don’t want this design because, when we don’t click on it, we can’t see the selected elements:
2
Answers
It does not seem that there is a native HTML5 way of helping you.
You can use select2 or similar libraries or try this one if it works for you
We could hide a normal select using media queries and have this one select options in it on a mobile
Some workarounds using checkboxes if you want to stick with native element.