Bootstrap form inputs now come in two styles: default and active (floating) label style; their HTML markup is slightly different.
Note that wrapping an input.form-control
inside a fieldset.form-group
or div.form-group
helps with layout styling. For labels, using .control-label
will apply a smaller, muted font style.
accessibility View Accessibility Notes
<!-- Input Group With Outside Add On --> <fieldset class="form-group"> <div class="input-group"> <span class="input-group-addon" id="sizing-addon2" aria-hidden="true"><i class="material-icons">group</i></span> <input aria-label="REPLACE ME" type="text" class="form-control" placeholder="Icon Add-on Outside"> </div> </fieldset> <!-- Input Group With Inside Add On --> <fieldset class="form-group"> <div class="input-group-inside"> <span class="input-group-addon" id="sizing-addon2" aria-hidden="true"><i class="material-icons">search</i></span> <input aria-label="REPLACE ME" type="text" class="form-control" placeholder="Icon Add-on Inside"> </div> </fieldset>
Make inputs, selects and textareas minimalist by placing the dynamic .form-active-labels
on the containing form
or div
.
IMPORTANT! Labels
must be placed after inputs
to work properly, and should not include the .control-label
class.
IMPORTANT! Do not use placeholder
text when utilizing the floating label; the label acts as both placeholder and then label on input:focus
and when the input contains a value.
Note: Because these Icon Add-on inputs have a label
, a ARIA-LABEL
is not needed sentiment_very_satisfied.
Note: Because these Button Add-on inputs have a label
, a ARIA-LABEL
is not needed sentiment_very_satisfied.
<form class="form-active-labels"> <fieldset class="form-group"> <input id="REPLACE ME" type="text" class="form-control"> <label for="REPLACE ME">With Active Label</label> </fieldset> </form>
Using Bootstrap selects
out-of-the-box.
accessibility View Accessibility Notes
<!-- Single Select --> <div class="form-group"> <label for="REPLACE ME" class="control-label">Basic Select</label> <select id="REPLACE ME" class="form-control c-select"> <option selected>What is your favourite type of cat?</option> <option value="fluffy">Fluffy</option> <option value="grumpy">Grumpy</option> ... </select> </div>
<!-- Multi Select --> <div class="form-group"> <label for="REPLACE ME" class="control-label">Multi-Select</label> <select id="REPLACE ME" class="form-control" multiple="" aria-multiselectable="true"> <option>Chocolate Mint</option> <option>Cookies and Cream</option> ... </select> </div>
Apply an Active Label style to Bootstrap select
.
accessibility View Accessibility Notes
<form class="form-active-labels"> <!-- Active Label Single Select --> <div class="form-group"> <select id="REPLACE ME" class="form-control c-select"> <option selected> </option> <option value="fluffy">Fluffy</option> <option value="grumpy">Grumpy</option> ... </select> <label for="REPLACE ME">Active Label Select</label> </div> </form>
Use Selectize.js to transform a plain select
into an ComboBox (text input + select dropdown + auto-suggest)—just place a .selectize
class on the select
! Create a MultiSelect using customization options available within the Selectize.js plugin.
accessibility View Accessibility Notes
Use Datepicker.js to add a date-select-field with a built in calendar, by placing a .datepicker
class on any text input
.
accessibility View Accessibility Notes
The textarea has a new style, so it looks similar to all other inputs.
accessibility View Accessibility Notes
<form> <fieldset class="form-group"> <label for="ta1" class="control-label">Select a Date:</label> <textarea id="ta1" class="form-control" placeholder="Placeholder text to prompt the user." rows="5"></textarea> </fieldset> </form>
IMPORTANT! Do not use placeholder
text when utilizing the floating label; the label acts as both placeholder and then label on input:focus
.
<form class="form-active-labels"> <div class="form-group"> <textarea id="REPLACE ME" class="form-control" rows="5"></textarea> <label for="REPLACE ME">Write Something Lengthy, The Label Will Float On :focus</label> </div> </form>
Bootstrap 4 introduces accessible and customized checkboxes which override default browser checkbox styles. — Source.
accessibility View Accessibility Notes
Use the class .c-inputs-stacked
on the containing .form-group
to push each checkbox to its own line.
<fieldset class="form-group"> <label class="c-input c-checkbox"> <input type="checkbox" name="optionsCheckboxes" id="cb-option1"> <span class="c-indicator"></span> Check and uncheck this label </label> </fieldset>
Style a checkbox
into a toggle switch by wrapping the input
with a .cbt
class. The add a label + span
"sandwich" directly after the input
to create the moving toggle switch.
Note: .cbt is an abreviation for checkbox toggle.
accessibility View Accessibility Notes
<fieldset class="form-group"> <div class="cbt-control"> <label for="cbt-1">Receive Notifications</label> <span class="cbt"> <input id="cbt-1" class="" type="checkbox" checked="" aria-label="REPLACE ME"> <label for="cbt-1" id="cbt-1-label"> <span class="checked"></span> <span class="toggle"></span> <span class="unchecked"></span> </label> </span> </div> </fieldset>
Bootstrap 4 introduces accessible and customized radios which override default browser radio styles. — Source.
Use the class .c-inputs-stacked
on the containing .form-group
to push each radio to its own line.
accessibility View Accessibility Notes
<fieldset class="form-group"> <legend>Do you use <fieldset>s with <legend>s for accessibility?</legend> <label class="c-input c-radio"> <input id="radio1" name="radio" type="radio"> <span class="c-indicator"></span> Yes, I do </label> <label class="c-input c-radio"> <input id="radio2" name="radio" type="radio"> <span class="c-indicator"></span> No, not at this time </label> </fieldset>
The option to style a selection of radios
as a button group is as simple as wrapping the radios
in the .btn-group.radio-btn-group
classes, and then apply .btn
classes to the labels
.
Radio Button Groups accept the standard button
styles and Button Group sizing classes.
accessibility View Accessibility Notes
<fieldset class="form-group"> <legend>Select a Layout:</legend> <div class="btn-group radio-btn-group" role="group" aria-label="Select Layout"> <label for="l-grid" class="btn btn-primary-outline" aria-label="Grid View"> <input id="l-grid" name="mode" type="radio" value="grid" checked> <i class="material-icons" aria-hidden="true">apps</i> Grid </label> <label for="l-list" class="btn btn-primary-outline" aria-label="List View"> <input id="l-list" name="mode" type="radio" value="list"> <i class="material-icons" aria-hidden="true">list</i> List </label> <label for="l-map" class="btn btn-primary-outline" aria-label="Map View"> <input id="l-map" name="mode" type="radio" value="map"> <i class="material-icons" aria-hidden="true">place</i> Map </label> </div> </fieldset>
The following elements and components are on-deck to be added to the UI Kit:
If you would like to see a element or component added to the kit, send an email to Natalie.