Forms
Examples and usage guidelines for form control styles, layout options, and custom components for creating a wide variety of forms with the help of Bootstrap Forms .
Overview
Bootstrap's form controls expand on Bootstrap Rebooted form styles with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices.
Be sure to use an appropriate type
attribute on all inputs (e.g., email
for email address or number
for numerical information) to take advantage of newer input controls like email verification, number selection, and more.
For more information, see Bootstrap Forms
Here's a quick example to demonstrate Bootstrap's form styles. Keep reading for documentation on required classes, form layout, and more.
Form controls
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.
Be sure to explore our custom form to further style <select>
s.
For file inputs, swap the .form-control
for .form-control-file
.
Custom form
Front customizes Bootstrap's forms, adds some styles to them along with hs.focus-state.js
library that adds .u-focus-state
classes to control states in various situations.
Pilled form
Use the .input-group-pill
modifier class to make forms more rounded (with a larger border-radius
and additional horizontal padding
).
Checkbox and radios
Default checkboxes and radios are improved upon with the help of .form-check
, a single class for both input types that improves the layout and behavior of their HTML elements. Checkboxes are for selecting one or several options in a list, while radios are for selecting one option from many.
Disabled checkboxes and radios are supported, but to provide a not-allowed
cursor on hover of the parent <label>
, you’ll need to add the disabled
attribute to the .form-check-input
. The disabled attribute will apply a lighter color to help indicate the input’s state.
Checkboxes and radios use are built to support HTML-based form validation and provide concise, accessible labels. As such, our <input>
s and <label>
s are sibling elements as opposed to an <input>
within a <label>
. This is slightly more verbose as you must specify id
and for
attributes to relate the <input>
and <label>
.
Default (stacked)
By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with .form-check
.
Inline checkbox
Group checkboxes or radios on the same horizontal row by adding .form-check-inline
to any .form-check
.
Switches
A switch has the markup of a custom checkbox but uses the .custom-switch
class to render a toggle switch. Switches also support the disabled
attribute.