Bootstrap provides useful classes for styling select dropdowns, checkboxes, radio buttons, switches, and other selection controls. These controls are commonly used in registration forms, admission forms, surveys, settings pages, search forms, and user preferences.
Selection controls allow users to choose one or more values from a set of available options.
Common selection controls include:
The choice of control depends on whether the user should select one option, multiple options, or turn a setting on or off.
The .form-select class styles a standard HTML
<select> element.
<select class="form-select">
<option selected>
Select Course
</option>
<option>
HTML
</option>
<option>
CSS
</option>
<option>
Python
</option>
</select>
A select control should normally have a meaningful label so that users know what they are expected to choose.
<label
class="form-label"
for="course">
Course
</label>
<select
class="form-select"
id="course">
<option selected>
Select Course
</option>
<option>
HTML
</option>
</select>
The selected attribute makes an option selected by
default.
<select class="form-select">
<option>HTML</option>
<option selected>
Python
</option>
<option>
JavaScript
</option>
</select>
The disabled attribute prevents users from interacting
with the select control.
<select
class="form-select"
disabled>
<option>
Select Course
</option>
</select>
The multiple attribute allows users to select more than
one option.
<select
class="form-select"
multiple>
<option>
HTML
</option>
<option>
CSS
</option>
<option>
JavaScript
</option>
<option>
Python
</option>
</select>
Multiple selections are useful when a user can choose several skills or categories.
The size attribute can display several options at once.
<select
class="form-select"
size="3">
<option>HTML</option>
<option>CSS</option>
<option>JavaScript</option>
<option>Python</option>
</select>
Use .form-select-lg to create a larger select control.
<select
class="form-select form-select-lg">
<option>
Large Select
</option>
</select>
Use .form-select-sm to create a smaller select control.
<select
class="form-select form-select-sm">
<option>
Small Select
</option>
</select>
The HTML <optgroup> element can group related
options inside a select control.
<select class="form-select">
<optgroup label="Frontend">
<option>
HTML
</option>
<option>
CSS
</option>
<option>
JavaScript
</option>
</optgroup>
<optgroup label="Backend">
<option>
PHP
</option>
<option>
Python
</option>
</optgroup>
</select>
A checkbox allows users to select or deselect an option.
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
id="html">
<label
class="form-check-label"
for="html">
HTML
</label>
</div>
Multiple checkboxes allow users to select several independent options.
Use the checked attribute to select a checkbox by default.
<input
class="form-check-input"
type="checkbox"
checked>
The disabled attribute prevents interaction with a
checkbox.
<input
class="form-check-input"
type="checkbox"
disabled>
Checkboxes are commonly used when users need to confirm terms and conditions.
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
id="terms"
required>
<label
class="form-check-label"
for="terms">
I agree to the terms.
</label>
</div>
Radio buttons are used when the user should choose one option from a group.
<div class="form-check">
<input
class="form-check-input"
type="radio"
name="gender"
id="male">
<label
class="form-check-label"
for="male">
Male
</label>
</div>
Radio buttons with the same name belong to the same group.
This normally allows only one option to be selected.
<input
type="radio"
name="course"
value="html">
<input
type="radio"
name="course"
value="python">
The checked attribute can select a radio button by default.
<input
class="form-check-input"
type="radio"
name="level"
checked>
A radio button can be disabled using the disabled
attribute.
<input
class="form-check-input"
type="radio"
disabled>
Bootstrap provides switch-style checkboxes using the
.form-switch class.
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
id="switch">
<label
class="form-check-label"
for="switch">
Enable Notifications
</label>
</div>
Add checked to a switch when it should be enabled by
default.
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
role="switch"
checked>
<label
class="form-check-label">
Dark Mode
</label>
</div>
A switch can be disabled using the disabled attribute.
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
role="switch"
disabled>
<label
class="form-check-label">
Service Unavailable
</label>
</div>
Use .form-check-inline when checkboxes should appear on
the same line when there is enough space.
<div class="form-check form-check-inline">
<input
class="form-check-input"
type="checkbox"
id="inlineHTML">
<label
class="form-check-label"
for="inlineHTML">
HTML
</label>
</div>
Radio buttons can also be displayed inline using
.form-check-inline.
<div class="form-check form-check-inline">
<input
class="form-check-input"
type="radio"
name="inlineLevel"
id="inlineBeginner">
<label
class="form-check-label"
for="inlineBeginner">
Beginner
</label>
</div>
Select controls can be placed inside Bootstrap's responsive grid.
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">
State
</label>
<select class="form-select">
<option selected>
Select State
</option>
<option>
Bihar
</option>
<option>
Delhi
</option>
</select>
</div>
</div>
Select controls and checkboxes can be combined in a single form.
Select your preferred learning mode:
A practical form may use all three selection controls for different types of choices.
Select learning mode:
Additional options:
Here is a practical admission form using select, radio, checkbox, and switch controls.
Select gender:
Additional requirements:
Follow these practices when creating selection controls:
selected carefully for default values.disabled when an option is unavailable.name for radio buttons in the same group.This complete example combines select, radio buttons, checkboxes, switches, and Bootstrap grid classes.
<form>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">
Course
</label>
<select
class="form-select"
required>
<option selected disabled>
Select Course
</option>
<option>
HTML
</option>
<option>
CSS
</option>
<option>
JavaScript
</option>
<option>
Python
</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">
Learning Mode
</label>
<div class="form-check">
<input
class="form-check-input"
type="radio"
name="mode"
id="online"
required>
<label
class="form-check-label"
for="online">
Online
</label>
</div>
<div class="form-check">
<input
class="form-check-input"
type="radio"
name="mode"
id="offline">
<label
class="form-check-label"
for="offline">
Offline
</label>
</div>
</div>
<div class="col-12 mb-3">
<label class="form-label">
Additional Services
</label>
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
id="notes">
<label
class="form-check-label"
for="notes">
Study Notes
</label>
</div>
<div class="form-check">
<input
class="form-check-input"
type="checkbox"
id="certificate">
<label
class="form-check-label"
for="certificate">
Certificate
</label>
</div>
</div>
<div class="col-12 mb-3">
<div class="form-check form-switch">
<input
class="form-check-input"
type="checkbox"
role="switch"
id="updates">
<label
class="form-check-label"
for="updates">
Receive Updates
</label>
</div>
</div>
<div class="col-12">
<button
type="submit"
class="btn btn-primary">
Submit
</button>
<button
type="reset"
class="btn btn-secondary">
Reset
</button>
</div>
</div>
</form>
.form-select to style select dropdowns.selected to choose an option by default.multiple when several select options can be chosen..form-select-lg for a large select control..form-select-sm for a small select control.<optgroup> to organize related select options..form-check for checkboxes and radio buttons.name for radio buttons in the same group..form-check-inline for inline selection controls..form-switch for switch-style checkboxes.checked for a selected checkbox or radio button by default.disabled when a selection control should not be available.Question: Which Bootstrap class is used to style a standard select dropdown?