Forms
Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms.
Form Control
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.
Input
Password
Textarea
Search
Url
Phone
Sizing
Set heights using classes like .form-control-lg
and .form-control-sm
.
Select
Customize the native <select>
s with custom CSS that changes the element’s initial appearance.
Multiple Select
Select Menu Sizes
You may also choose from small and large custom selects to match our similarly sized text inputs.
Indeterminate
Checkboxes can utilize the :indeterminate
pseudo class when manually set via JavaScript (there is no available HTML attribute for specifying it).
Disabled
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.
Radios
Disabled
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.
Switches
A switch has the markup of a custom checkbox but uses the.form-switch
class to render a toggle switch. Consider usingrole="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 thedisabled
attribute.
Validation states
It provides valuable, actionable feedback to your users with HTML5 form validation.
Disabled & Readonly Fields
Use readonly
or disabled
attributes for .form-control
Range
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.
Disabled
Add thedisabled
boolean attribute on an input to give it a grayed out appearance and remove pointer events.
Mix and max
Add the disabled
boolean attribute on an input to give it a grayed out appearance and remove pointer events.
Steps
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"
.