{# Settings #} {% set root = "../../../" %} {% set mainNavActive_1 = "shortcodes" %} {% set sidebarNavActive_1 = "shortcode-base-forms-bootstrap" %} {% set title = "Bootstrap Forms" %} {% include "html/assets/include/nunjucks/partials/head.njk" %} {% include "html/assets/include/nunjucks/partials/core-fonts.njk" %} {% include "html/assets/include/nunjucks/partials/core-css.njk" %} {% include "html/assets/include/nunjucks/partials/core-icons.njk" %} {% include "html/assets/include/nunjucks/partials/css/css-dzsparallaxer.njk" %} {% include "html/assets/include/nunjucks/partials/css/css-showcode.njk" %} {% include "html/assets/include/nunjucks/partials/css/css-unify.njk" %} {% include "html/assets/include/nunjucks/partials/css/css-custom.njk" %}
{% include "html/assets/include/nunjucks/partials/blocks/headers/header-main.njk" %} {% include "html/assets/include/nunjucks/partials/blocks/sidebars/sidebar-shortcode-nav.njk" %} {% include "html/assets/include/nunjucks/partials/blocks/page-title/shortcode-page-title/shortcode-page-title-base.njk" %}

Form Controls

Bootstrap’s form controls expand on our Rebooted form styles with classes. Use these classes to opt into their customized displays for a more consistent rendering across browsers and devices. The example form below demonstrates common HTML form elements that receive updated styles from Bootstrap with additional classes.

General Controls

Remember, since Bootstrap utilizes the HTML5 doctype, all inputs must have a type attribute.

We'll never share your email with anyone else.
This is some placeholder block-level help text for the above input. It's a bit lighter and easily wraps to a new line.
Radio buttons
{% set contentTarget = "#shortcode1" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Textual Inputs

Here are examples of .form-control applied to each textual HTML5 <input> type.

{% set contentTarget = "#shortcode2" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Form Layouts

Since Bootstrap applies display: block and width: 100% to almost all our form controls, forms will by default stack vertically. Additional classes can be used to vary this layout on a per-form basis.

Form Groups

The .form-group class is the easiest way to add some structure to forms. Its only purpose is to provide margin-bottom around a label and control pairing.

As a bonus, since it’s a class you can use it with <fieldset> s, <div>s, or nearly any other element.


Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.

{% set contentTarget = "#shortcode3" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Inline Forms

Use the .form-inline class to display a series of labels, form controls, and buttons on a single horizontal row.

@

Must be 8-20 characters long.
{% set contentTarget = "#shortcode4" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Inline Forms custom form controls

Custom form controls and selects are also supported.

{% set contentTarget = "#shortcode5" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Horizontal Forms using the grid

Add the .row class to form groups and use the .col-*-* classes to specify the width of your labels and controls.

Be sure to add .col-form-label to your <label>s as well so they’re vertically centered with their associated form controls.

Radios
{% set contentTarget = "#shortcode6" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Horizontal form sizes

Grid-based form layouts also support large and small inputs.

{% set contentTarget = "#shortcode7" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Checkboxes 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.

Default (stacked)

By default, any number of checkboxes and radios that are immediate sibling will be vertically stacked and appropriately spaced with .form-check.


{% set contentTarget = "#shortcode8" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Inline

Group checkboxes or radios on the same horizontal row by adding .form-check-inline to any .form-check.


{% set contentTarget = "#shortcode9" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Without Labels

Should you have no text within the <label>, the input is positioned as you’d expect. Currently only works on non-inline checkboxes and radios.


{% set contentTarget = "#shortcode10" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Static Controls

When you need to place plain text next to a form label within a form, use the .form-control-static class on an element of your choice.

Inline Forms

email@example.com


email@example.com

{% set contentTarget = "#shortcode11" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Disabled and Readonly States

Add the disabled boolean attribute on an input to prevent user interactions. Disabled inputs appear lighter and add a not-allowed cursor. Also, read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.

Disabled

Add the disabled attribute to a <fieldset> to disable all the controls within.

{% set contentTarget = "#shortcode12" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Readonly Inputs

Add the readonly boolean attribute on an input to prevent modification of the input’s value

{% set contentTarget = "#shortcode13" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Control and Column Sizing

Bootstrap comes with three control form sizes: small, default and large. For column sizing, just wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths.

Inputs

Set heights using classes like .form-control-lg, and set widths using grid column classes like .col-lg-*.

{% set contentTarget = "#shortcode14" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Selects

Also .form-control-lg class is used for selects.

{% set contentTarget = "#shortcode15" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Column Sizing

Wrap inputs in grid columns, or any custom parent element.

{% set contentTarget = "#shortcode16" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Validation

Bootstrap includes validation styles for danger, warning, and success states on most form controls. Generally speaking, you’ll want to use a particular state for specific types of feedback: danger, warning and success states.

Form Groups

Here are some examples of the aforementioned classes in action.

First up is your standard left-aligned fields with labels, help text, and validation messaging.

Example help text that remains unchanged.
Example help text that remains unchanged.
Example help text that remains unchanged.
{% set contentTarget = "#shortcode17" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Inline Forms

Those same states can also be used with horizontal forms.

Example help text that remains unchanged.
Example help text that remains unchanged.
Example help text that remains unchanged.
{% set contentTarget = "#shortcode18" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Checkboxes and Radios

Checkboxes and radios are also supported.


{% set contentTarget = "#shortcode19" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Custom Forms

For even more customization and cross browser consistency, use our completely custom form elements to replace the browser defaults. They’re built on top of semantic and accessible markup, so they’re solid replacements for any default form control.

Checkboxes and Radios

Here are some custom checkboxes and radios examples.





{% set contentTarget = "#shortcode20" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Select Menu

Custom <select> menus need only a custom class, .custom-select to trigger the custom styles.

{% set contentTarget = "#shortcode21" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

File Browser

The file input is the most gnarly of the bunch and require additional JavaScript if you’d like to hook them up with functional Choose file… and selected file name text.

{% set contentTarget = "#shortcode22" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Input Group

Easily extend form controls by adding text, buttons, or button groups on either side of textual <input>s.

Basic Example

Place one add-on or button on either side of an input. You may also place one on both sides of an input.

Bootstrap does not support multiple form-controls in a single input group.

$ 0.00
{% set contentTarget = "#shortcode23" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Sizing

Add the relative form sizing classes to the .input-group itself and contents within will automatically resize—no need for repeating the form control size classes on each element.



{% set contentTarget = "#shortcode24" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Checkboxes and Radio Addons

Place any checkbox or radio option within an input group’s addon instead of text.

{% set contentTarget = "#shortcode25" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Multiple Addons

Multiple add-ons are supported and can be mixed with checkbox and radio input versions.

$
$
{% set contentTarget = "#shortcode26" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Button Addons

Buttons in input groups must wrapped in a .input-group-btn for proper alignment and sizing. This is required due to default browser styles that cannot be overridden.


{% set contentTarget = "#shortcode27" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Buttons with Dropdowns

Dropdowns buttons in input groups also must be wrapped in a .input-group-btn.

{% set contentTarget = "#shortcode28" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}

Segmented Buttons

{% set contentTarget = "#shortcode29" %} {% set modalID = "#modalMarkup" %} {% include "html/assets/include/nunjucks/partials/blocks/show-code.njk" %}
{% include "html/assets/include/nunjucks/partials/blocks/cta/cta-main.njk" %} {% include "html/assets/include/nunjucks/partials/blocks/footers/footer-main.njk" %} {% include "html/assets/include/nunjucks/partials/blocks/footers/copyright-footer-main.njk" %} {% include "html/assets/include/nunjucks/partials/blocks/go-to-top/go-to-top-1.njk" %}
{% include "html/assets/include/nunjucks/partials/blocks/modals/modal-markup.njk" %} {% include "html/assets/include/nunjucks/partials/core-js.njk" %} {% include "html/assets/include/nunjucks/partials/js/js-dzsparallaxer.njk" %} {% include "html/assets/include/nunjucks/partials/js/js-jquery-ui-core.njk" %} {% include "html/assets/include/nunjucks/partials/js/js-show-code.njk" %}