Bootstrap5 Dropdown Menus
Dropdown menus can be single-select or multi-select.
Single-select Dropdown Menu:
Multi-select Dropdown Menu:
In Bootstrap5, the <select>
element can be rendered using the .form-select
class:
Example
<select class="form-select">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
Dropdown menus can be resized using the .form-select-lg
or .form-select-sm
classes:
Example
<select class="form-select form-select-lg">
<select class="form-select">
<select class="form-select form-select-sm">
The effect is shown in the following image:
The disabled
attribute can prevent the dropdown menu from being selected:
Example
<select class="form-select" disabled>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
Data List
Bootstrap can also set dropdown menus for <input>
elements using the datalist tag:
The following example selects a website from a list:
Example
<label for="browser" class="form-label">Choose your favorite website:</label>
<input class="form-control" list="sites" name="site" id="site">
<datalist id="sites">
<option value="Google">
<option value="tutorialpro">
<option value="Taobao">
<option value="Wiki">
<option value="Zhihu">
</datalist>
The effect is shown in the following image: