Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms.
Textual form controls—like <input>
s,
<select>
s, and <textarea>
s—are styled with the
.form-control
class. Included are styles for general appearance, focus state, sizing,
and more.
Set heights using classes like .form-control-lg
and .form-control-sm
.
Customize the native <select>
s with custom CSS that changes the element’s initial
appearance.
You may also choose from small and large custom selects to match our similarly sized text inputs.
Checkboxes can utilize the :indeterminate
pseudo class when manually set via
JavaScript (there is no available HTML attribute for specifying it).
Add the disabled
attribute and the associated <label>
s are
automatically styled to match with a lighter color to help indicate the input’s state.
Add the disabled
attribute and the associated <label>
s are
automatically styled to match with a lighter color to help indicate the input’s state.
A switch has the markup of a custom checkbox but uses the .form-switch
class to
render a toggle switch. Consider using role="switch"
to more accurately convey the
nature of the control to assistive technologies that support this role. In older assistive
technologies, it will simply be announced as a regular checkbox as a fallback. Switches also
support the disabled
attribute.
It provides valuable, actionable feedback to your users with HTML5 form validation.
Use readonly
or disabled
attributes for
.form-control
Create custom <input
type="range">
controls with .custom-range.
The
track (the background) and thumb (the value) are both styled to appear the same across browsers.
As only IE
and Firefox support “filling” their track from the left or right of the thumb as a means to
visually indicate progress, we do not currently support it.
Add the disabled
boolean attribute on an input to give it a grayed out appearance
and remove pointer events.
Add the disabled
boolean attribute on an input to give it a grayed out appearance
and remove pointer events.
By default, range inputs “snap” to integer values. To change this, you can specify a
step
value. In the example below, we double the number of steps by using
step="0.5"
.