Disabled
Add a disabled
attribute to the select
to diable making a selection or making changes to the current selected option. Add a disabled
attribute to an option to prevent its selection.
Selects are form controls that allow users to make a single choice from a list of options.
<div class="form-group">
<label for="select-1">Select Label</label>
<select id="select-1" class="form-control">
<option>Choose an option</option>
<option>Option 1</option>
<option>Option 2</option>
</select>
</div>
Add a disabled
attribute to the select
to diable making a selection or making changes to the current selected option. Add a disabled
attribute to an option to prevent its selection.
To indicate an error state, add .has-error
to the parent element of the select
.
Error message
To create placeholder text for a select control, add an option
with the placeholder text and add disabled
and selected
attributes to it.
Options can be grouped and labeled with optgroup
.
<div class="form-group">
<label for="optiongroup-1">Select Label</label>
<select id="optiongroup-1" class="form-control">
<optgroup label="Numbers">
<option>1</option>
<option>2</option>
<option>3</option>
</optgroup>
<optgroup label="Letters">
<option>A</option>
<option>B</option>
<option>C</option>
</optgroup>
</select>
</div>