Skip to main content
Figuration v4.4 is now available!
Content

Styles for displaying content with some of the most commonly used HTML elements, including normalization, typography, images, tables, buttons, forms, and more.

Forms

Figuration provides several form control styles, layout options, and custom components for creating a wide variety of forms.

Page Contents

Form Controls

Figuration's form controls expand on the 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 Figuration with additional classes.

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

Alternatives to Hidden Labels

Assistive technologies such as screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the .sr-only class. There are further alternative methods of providing a label for assistive technologies, such as the aria-label, aria-labelledby or title attribute. If none of these are present, assistive technologies may resort to using the placeholder attribute, if present, but note that use of placeholder as a replacement for other labelling methods is not advised.

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
Checkbox
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleSelect1">Example select</label>
<select class="form-control" id="exampleSelect1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">
<label for="exampleSelect2">Example multiple select</label>
<select multiple class="form-control" id="exampleSelect2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
<div class="form-group">
<label for="exampleTextarea">Example textarea</label>
<textarea class="form-control" id="exampleTextarea" rows="3"></textarea>
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" class="form-control-file" id="exampleInputFile" aria-describedby="fileHelp">
<small id="fileHelp" class="form-text text-muted">This is some placeholder block-level help text for the above input. It's a bit lighter and easily wraps to a new line.</small>
</div>
<div class="form-group">
<label for="exampleInputColor">Color input</label>
<input type="color" class="form-control-color" value="#117dba" id="exampleInputColor">
</div>
<fieldset class="form-group">
<legend>Radio buttons</legend>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optionsRadios" id="optionsRadios1" value="option1" checked>
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optionsRadios" id="optionsRadios2" value="option2">
Option two can be something else and selecting it will deselect option one
</label>
</div>
<div class="form-check disabled">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
Option three is disabled
</label>
</div>
</fieldset>
<div class="form-check">
<fieldset>
<legend>Checkbox</legend>
<label class="form-check-label">
<input type="checkbox" class="form-check-input"> Check me out
</label>
</fieldset>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>

Below is a complete list of the specific form controls supported by Figuration and the classes that customize them. Additional documentation is available for each group.

Classes Used for Supported variations
.form-group Any group of form controls Use with any block-level element like <fieldset> or <div>
.form-control/ Textual inputs text, password, datetime-local, date, month, time, week, number, email, url, search, tel
Select menus multiple, size
Textareas N/A
.form-control-color Color inputs color
.form-control-file File inputs file
.form-check Checkboxes and radios N/A

Textual Inputs

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

<div class="form-group row">
<label for="example-text-input" class="col-2 form-control-label">Text</label>
<div class="col-10">
<input class="form-control" type="text" value="awesome frameworks" id="example-text-input">
</div>
</div>
<div class="form-group row">
<label for="example-search-input" class="col-2 form-control-label">Search</label>
<div class="col-10">
<input class="form-control" type="search" value="How do I move mountains" id="example-search-input">
</div>
</div>
<div class="form-group row">
<label for="example-email-input" class="col-2 form-control-label">Email</label>
<div class="col-10">
<input class="form-control" type="email" value="name@example.com" id="example-email-input">
</div>
</div>
<div class="form-group row">
<label for="example-url-input" class="col-2 form-control-label">URL</label>
<div class="col-10">
<input class="form-control" type="url" value="http://cast.org/" id="example-url-input">
</div>
</div>
<div class="form-group row">
<label for="example-tel-input" class="col-2 form-control-label">Telephone</label>
<div class="col-10">
<input class="form-control" type="tel" value="1-(555)-555-5555" id="example-tel-input">
</div>
</div>
<div class="form-group row">
<label for="example-password-input" class="col-2 form-control-label">Password</label>
<div class="col-10">
<input class="form-control" type="password" value="hunter2" id="example-password-input">
</div>
</div>
<div class="form-group row">
<label for="example-number-input" class="col-2 form-control-label">Number</label>
<div class="col-10">
<input class="form-control" type="number" value="42" id="example-number-input">
</div>
</div>
<div class="form-group row">
<label for="example-datetime-local-input" class="col-2 form-control-label">Date and time</label>
<div class="col-10">
<input class="form-control" type="datetime-local" value="2011-08-19T13:45:00" id="example-datetime-local-input">
</div>
</div>
<div class="form-group row">
<label for="example-date-input" class="col-2 form-control-label">Date</label>
<div class="col-10">
<input class="form-control" type="date" value="2011-08-19" id="example-date-input">
</div>
</div>
<div class="form-group row">
<label for="example-month-input" class="col-2 form-control-label">Month</label>
<div class="col-10">
<input class="form-control" type="month" value="2011-08" id="example-month-input">
</div>
</div>
<div class="form-group row">
<label for="example-week-input" class="col-2 form-control-label">Week</label>
<div class="col-10">
<input class="form-control" type="week" value="2011-W33" id="example-week-input">
</div>
</div>
<div class="form-group row">
<label for="example-time-input" class="col-2 form-control-label">Time</label>
<div class="col-10">
<input class="form-control" type="time" value="13:45:00" id="example-time-input">
</div>
</div>

Form Layouts

Since Figuration 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.

<form>
<div class="form-group">
<label class="form-control-label" for="formGroupExampleInput">Example label</label>
<input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input">
</div>
<div class="form-group">
<label class="form-control-label" for="formGroupExampleInput2">Another label</label>
<input type="text" class="form-control" id="formGroupExampleInput2" placeholder="Another input">
</div>
</form>

Inline Forms

Use the .form-inline class to display a series of labels, form controls, and buttons on a single horizontal row. Form controls within inline forms vary slightly from their default states.

  • Controls are display: flex, collapsing any HTML white space and allowing you to provide alignment control with spacing and flexbox utilities.
  • Controls and input groups receive width: auto to override the Figuration default width: 100%.
  • Controls only appear inline in viewports that are at least 36em/576px wide to account for narrow viewports on mobile devices.

You may need to manually address the width and alignment of individual form controls with spacing utilities (as shown below). Lastly, as shown below, you should always include a <label> with each form control, even if you need to hide it from non-screenreader users with .sr-only.

<form class="form-inline">
<div class="form-group mb-0_5 me-sm-0_5 mb-sm-0">
<label for="inlineName0" class="form-control-label me-sm-0_5">Name</label>
<input type="text" class="form-control" id="inlineName0" placeholder="Jane Doe">
</div>
<div class="form-group mb-0_5 me-sm-0_5 mb-sm-0">
<label for="inlineEmail0" class="form-control-label me-sm-0_5">Email</label>
<input type="email" class="form-control" id="inlineEmail0" placeholder="jane.doe@example.com">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<form class="form-inline form-inline-checkbox">
<div class="form-group mb-0_5 me-sm-0_5 mb-sm-0">
<label class="sr-only" for="inlineEmail1">Email address</label>
<input type="email" class="form-control" id="inlineEmail1" placeholder="Enter email">
</div>
<div class="form-group mb-0_5 me-sm-0_5 mb-sm-0">
<label class="sr-only" for="inlinePassword1">Password</label>
<input type="password" class="form-control" id="inlinePassword1" placeholder="Password">
</div>
<div class="form-check mb-0_5 me-sm-0_5 mb-sm-0">
<label class="form-check-label">
<input class="form-check-input" type="checkbox"> Remember me
</label>
</div>
<button type="submit" class="btn btn-primary">Sign in</button>
</form>

Input groups are supported.

$
.00
<form class="form-inline">
<div class="form-group me-sm-0_5">
<label class="sr-only" for="inputAmount2">Amount (in dollars)</label>
<div class="input-group">
<div class="input-group-addon">$</div>
<input type="text" class="form-control" id="inputAmount2" placeholder="Amount">
<div class="input-group-addon">.00</div>
</div>
</div>
<button type="submit" class="btn btn-primary">Transfer cash</button>
</form>

Custom form controls and selects are also supported.

<form class="form-inline">
<label class="form-control-label me-sm-0_5" for="inlinePref4">Preference</label>
<select class="custom-select mb-0_5 me-sm-0_5 mb-sm-0" id="inlinePref4">
<option selected>Choose...</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<label class="custom-control custom-checkbox mb-0_5 me-sm-0_5 mb-sm-0">
<input type="checkbox" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Remember my preference</span>
</label>
<button type="submit" class="btn btn-primary">Submit</button>
</form>

Using the Grid

For more structured form layouts that are also responsive, you can utilize Figuration's predefined grid classes or mixins to create horizontal forms. 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 .form-control-label to your <label>s as well so they're vertically centered with their associated form controls. For <legend> elements, you can use .form-control-legend to make them appear similar to regular <label> elements.

Radios
Checkbox
<form>
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 form-control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword3" placeholder="Password">
</div>
</div>
<fieldset class="form-group">
<div class="row">
<legend class="col-sm-2 form-control-legend">Radios</legend>
<div class="col-sm-10">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios1" value="option1" checked>
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios2" value="option2">
Option two can be something else and selecting it will deselect option one
</label>
</div>
<div class="form-check disabled">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="gridRadios" id="gridRadios3" value="option3" disabled>
Option three is disabled
</label>
</div>
</div>
</div>
</fieldset>
<fieldset class="form-group">
<div class="row">
<legend class="col-sm-2 form-control-legend">Checkbox</legend>
<div class="col-sm-10">
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox"> Check me out
</label>
</div>
</div>
</div>
</fieldset>
<div class="form-group row">
<div class="offset-sm-2 col-sm-10">
<button type="submit" class="btn btn-primary">Sign in</button>
</div>
</div>
</form>

Grid-based form layouts also support control sizing.

<form>
<div class="form-group row">
<label for="lgFormGroupInput" class="col-sm-2 form-control-label form-control-label-lg">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-lg" id="lgFormGroupInput" placeholder="you@example.com">
</div>
</div>
<div class="form-group row">
<label for="smFormGroupInput" class="col-sm-2 form-control-label form-control-label-sm">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-sm" id="smFormGroupInput" placeholder="you@example.com">
</div>
</div>
</form>

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.

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 class to the parent .form-check. The disabled class will also lighten the text color to help indicate the input's state.

Default (stacked)

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

<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" value="">
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="form-check disabled">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" value="" disabled>
Option two is disabled
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios1" value="option1" checked>
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="option2">
Option two can be something else and selecting it will deselect option one
</label>
</div>
<div class="form-check disabled">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios3" value="option3" disabled>
Option three is disabled
</label>
</div>

Inline

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

<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1"> 1
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" id="inlineCheckbox2" value="option2"> 2
</label>
</div>
<div class="form-check form-check-inline disabled">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" id="inlineCheckbox3" value="option3" disabled> 3
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> 1
</label>
</div>
<div class="form-check form-check-inline">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> 2
</label>
</div>
<div class="form-check form-check-inline disabled">
<label class="form-check-label">
<input class="form-check-input" type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3" disabled> 3
</label>
</div>

Without Labels

Add .position-static to inputs within .form-check that don't have any label text. Remember to still provide some form of label for assistive technologies (for instance, using aria-label).

<div class="form-check">
<label class="form-check-label">
<input class="form-check-input position-static" type="checkbox" id="blankCheckbox" value="option1" aria-label="...">
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input position-static" type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="...">
</label>
</div>

Static Controls

When you want to have read-only fields in your form styled as plain text, use the .form-control-static class to remove the default form field styling and preserve the correct margin and padding.

<form>
<div class="form-group row">
<label for="inputEmail" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="text" readonly class="form-control-static" id="inputEmail" value="email@example.com">
</div>
</div>
<div class="form-group row">
<label for="inputPassword" class="col-sm-2 form-control-label">Password</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="inputPassword" placeholder="Password">
</div>
</div>
</form>
<form class="form-inline">
<div class="form-group me-0_5">
<label for="inputEmail2" class="sr-only">Email</label>
<input type="text" readonly class="form-control-static" id="inputEmail2" value="email@example.com">
</div>
<div class="form-group me-0_5">
<label for="inputPassword2" class="sr-only">Password</label>
<input type="password" class="form-control" id="inputPassword2" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Confirm identity</button>
</form>

Disabled States

Add the disabled boolean attribute on an input to prevent user interactions. Disabled inputs appear lighter and add a not-allowed cursor.

<input class="form-control" id="disabledInput" type="text" placeholder="Disabled input" disabled>

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

<form>
<fieldset disabled>
<div class="form-group">
<label for="disabledTextInput">Disabled input</label>
<input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled input">
</div>
<div class="form-group">
<label for="disabledSelect">Disabled select menu</label>
<select id="disabledSelect" class="form-control">
<option>Disabled select</option>
</select>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input"> Can't check this
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>

Caveat About Link Functionality of <a>

By default, browsers will treat all native form controls (<input>, <select> and <button> elements) inside a <fieldset disabled> as disabled, preventing both keyboard and mouse interactions on them. However, if your form also includes <a ... class="btn btn-*"> elements, these will only be given a style of pointer-events: none. As noted in the section about disabled state for buttons (and specifically in the sub-section for anchor elements), this CSS property is not yet standardized and isn't fully supported in all browsers, and won't prevent keyboard users from being able to focus or activate these links. So to be safe, use custom JavaScript to disable such links.

Cross-browser Compatibility

While Figuration will apply these styles in all browsers, Internet Explorer 11 and below don't fully support the disabled attribute on a <fieldset>. Use custom JavaScript to disable the fieldset in these browsers.

Readonly Inputs

Add the readonly boolean attribute on an input to prevent modification of the input's value. Read-only inputs appear lighter (just like disabled inputs), but retain the standard cursor.

<input class="form-control" type="text" placeholder="Readonly input" readonly>

Control Sizing

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

<input class="form-control form-control-xl" type="text" placeholder=".form-control-xl">
<input class="form-control form-control-lg" type="text" placeholder=".form-control-lg">
<input class="form-control" type="text" placeholder="Default input">
<input class="form-control form-control-sm" type="text" placeholder=".form-control-sm">
<input class="form-control form-control-xs" type="text" placeholder=".form-control-xs">
<select class="form-control form-control-xl">
<option>Extra large select</option>
</select>
<select class="form-control form-control-lg">
<option>Large select</option>
</select>
<select class="form-control">
<option>Default select</option>
</select>
<select class="form-control form-control-sm">
<option>Small select</option>
</select>
<select class="form-control form-control-xs">
<option>Extra small select</option>
</select>

Label and Static Sizing

Just like sizing the form inputs, you can size labels by adding .form-control-label{-size}, and static items with .form-control-static{-size} classes.

email@example.com

email@example.com

email@example.com

email@example.com

email@example.com

<div class="form-group row">
<label class="col-sm-2 form-control-label form-control-label-xs">Email</label>
<div class="col-sm-10">
<p class="form-control-static form-control-static-xs">email@example.com</p>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 form-control-label form-control-label-sm">Email</label>
<div class="col-sm-10">
<p class="form-control-static form-control-static-sm">email@example.com</p>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<p class="form-control-static">email@example.com</p>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 form-control-label form-control-label-lg">Email</label>
<div class="col-sm-10">
<p class="form-control-static form-control-static-lg">email@example.com</p>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 form-control-label form-control-label-xl">Email</label>
<div class="col-sm-10">
<p class="form-control-static form-control-static-xl">email@example.com</p>
</div>
</div>

Column Sizing

Wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths.

<div class="row">
<div class="col-2">
<input type="text" class="form-control" placeholder=".col-2">
</div>
<div class="col-3">
<input type="text" class="form-control" placeholder=".col-3">
</div>
<div class="col-4">
<input type="text" class="form-control" placeholder=".col-4">
</div>
</div>

Help Text

Block-level help text in forms can be created using .form-text. Inline help text can be flexibly implemented using any inline HTML element and utility classes like .text-muted.

Associating Help Text With Form Controls

Help text should be explicitly associated with the form control it relates to using the aria-describedby attribute. This will ensure that assistive technologies—such as screen readers—will announce this help text when the user focuses or enters the control.

Block Level

Block help text—for below inputs or for longer lines of help text—can be easily achieved with .form-text. This class includes display: block and adds some top margin for easy spacing from the inputs above.

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

<label for="inputPassword5">Password</label>
<input type="password" id="inputPassword5" class="form-control" aria-describedby="passwordHelpBlock">
<p id="passwordHelpBlock" class="form-text text-muted">
Your password must be 8-20 characters long, contain letters and numbers, and must not contain spaces, special characters, or emoji.
</p>

Inline

Inline text can use any typical inline HTML element (be it a <small>, <span>, or something else).

Must be 8-20 characters long.
<form class="form-inline">
<div class="form-group">
<label for="inputPassword4" class="me-0_5">Password</label>
<input type="password" id="inputPassword4" class="form-control me-0_5" aria-describedby="passwordHelpInline">
<small id="passwordHelpInline" class="text-muted">
Must be 8-20 characters long.
</small>
</div>
</form>

Validation

Figuration includes validation styles for danger, warning, and success states on form controls. Here's a rundown of how they work:

How It Works

  • To use, add .has-warning, .has-danger, or .has-success to the parent element. Any .form-control-label, .form-control, or custom form element will receive the validation styles.
  • Contextual validation text, in addition to your usual form field help text, can be added with the use of .form-control-feedback. This text will adapt to the parent .has-* class. By default it only includes a bit of margin for spacing and a modified color for each state.
  • Add a visual validation icon to an input field by adding the .form-control-icon class to a .form-control element. These icons will also scale with the component size.
  • Validation icons are url()s configured via Sass variables that are applied to background-image declarations for each state.
  • You may use your own base64 PNGs or SVGs by updating the Sass variables and recompiling.
  • Icons can also be disabled entirely by setting the variables to none or commenting out the source Sass.

Defining States

Generally speaking, you'll want to use a particular state for specific types of feedback:

  • Danger is great for when there's a blocking or required field. A user must fill in this field properly to submit the form.
  • Warning works well for input values that are in progress, like password strength, or soft validation before a user attempts to submit a form.
  • And lastly, success is ideal for situations when you have per-field validation throughout a form and want to encourage a user through the rest of the fields.

Conveying Meaning to Assistive Technologies

Please refer to the Accessiblity notes about conveying meaning with color.

Here are some examples of the aforementioned classes in action.

Examples

Example help text that remains unchanged.
Example help text that remains unchanged.
Example help text that remains unchanged.
<div class="form-group has-success">
<label class="form-control-label" for="inputSuccess1">Input with success</label>
<input type="text" class="form-control form-control-icon" id="inputSuccess1">
<div class="form-control-feedback">Success! You've done it.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
<div class="form-group has-warning">
<label class="form-control-label" for="inputWarning1">Input with warning</label>
<input type="text" class="form-control form-control-icon" id="inputWarning1">
<div class="form-control-feedback">Check the formatting of that and try again.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
<div class="form-group has-danger">
<label class="form-control-label" for="inputDanger1">Input with danger</label>
<input type="text" class="form-control form-control-icon" id="inputDanger1">
<div class="form-control-feedback">Sorry, that username's taken. Try another?</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
<div class="form-check has-success">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" id="checkboxSuccess" value="option1">
Checkbox with success
</label>
</div>
<div class="form-check has-warning">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" id="checkboxWarning" value="option1">
Checkbox with warning
</label>
</div>
<div class="form-check has-danger">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" id="checkboxDanger" value="option1">
Checkbox with danger
</label>
</div>

Also a slightly more horizontal layout.

Example help text that remains unchanged.
Example help text that remains unchanged.
Example help text that remains unchanged.
<div class="form-group row has-success">
<label for="inputHorizontalSuccess" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-icon" id="inputHorizontalSuccess" placeholder="name@example.com">
<div class="form-control-feedback">Success! You've done it.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
</div>
<div class="form-group row has-warning">
<label for="inputHorizontalWarning" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-icon" id="inputHorizontalWarning" placeholder="name@example.com">
<div class="form-control-feedback">Check the formatting of that and try again.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
</div>
<div class="form-group row has-danger">
<label for="inputHorizontalDnger" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-icon" id="inputHorizontalDnger" placeholder="name@example.com">
<div class="form-control-feedback">Sorry, that username's taken. Try another?</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
</div>

Validation icons can be added optionally.

Example help text that remains unchanged.
Example help text that remains unchanged.
<div class="form-group row has-success">
<label for="inputOptSuccessY" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-icon" id="inputOptSuccessY" placeholder="name@example.com">
<div class="form-control-feedback">Success! You've done it.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
</div>
<div class="form-group row has-success">
<label for="inputOptSuccessN" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputOptSuccessN" placeholder="name@example.com">
<div class="form-control-feedback">Success! You've done it.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
</div>

Validation icons will also scale with the component size.

Example help text that remains unchanged.
Example help text that remains unchanged.
<div class="form-group row has-success">
<label for="inputSizeSuccessSm" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-sm form-control-icon" id="inputSizeSuccessSm" placeholder="name@example.com">
<div class="form-control-feedback">Success! You've done it.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
</div>
<div class="form-group row has-success">
<label for="inputSizeSuccessLg" class="col-sm-2 form-control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control form-control-lg form-control-icon" id="inputSizeSuccessLg" placeholder="name@example.com">
<div class="form-control-feedback">Success! You've done it.</div>
<small class="form-text text-muted">Example help text that remains unchanged.</small>
</div>
</div>

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

Each checkbox and radio is wrapped in a <label> for three reasons:

  • It provides a larger hit areas for checking the control.
  • It provides a helpful and semantic wrapper to help us replace the default <input>s.
  • It triggers the state of the <input> automatically, meaning no JavaScript is required.

We hide the default <input> with opacity and use the .custom-control-indicator to build a new custom form indicator in its place. Unfortunately we can't build a custom one from just the <input> because CSS's content doesn't work on that element.

We use the sibling selector (~) for all our <input> states—like :checked—to properly style our custom form indicator. When combined with the .custom-control-description class, we can also style the text for each item based on the <input>'s state.

In the checked states, we use base64 embedded SVG icons from Open Iconic. This provides us the best control for styling and positioning across browsers and devices.

Checkboxes

<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Check this custom checkbox</span>
</label>

Custom checkboxes can also utilize the :indeterminate pseudo class when manually set via JavaScript (there is no available HTML attribute for specifying it).

If you're using jQuery, something like this should suffice:

$('.your-checkbox').prop('indeterminate', true)

Radios

<label class="custom-control custom-radio">
<input id="radio1" name="radio" type="radio" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Toggle this custom radio</span>
</label>
<label class="custom-control custom-radio">
<input id="radio2" name="radio" type="radio" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Or toggle this other custom radio</span>
</label>

Disabled

Custom checkboxes and radios can also be disabled. Add the disabled boolean attribute to the <input> and the custom indicator and label description will be automatically styled.

<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" disabled>
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Check this custom checkbox</span>
</label>

<label class="custom-control custom-radio">
<input id="radio3" name="radioDisabled" type="radio" class="custom-control-input" disabled>
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Toggle this custom radio</span>
</label>

Validation States

Add other states to your custom forms with our validation classes.

<div class="form-group has-success">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Check this custom checkbox</span>
</label>
</div>
<div class="form-group has-warning">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Check this custom checkbox</span>
</label>
</div>
<div class="form-group has-danger mb-0">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Check this custom checkbox</span>
</label>
</div>

Stacked

Custom checkboxes and radios are inline to start. Add a parent with class .custom-controls-stacked to ensure each form control is on separate lines.

<div class="custom-controls-stacked">
<label class="custom-control custom-radio">
<input id="radioStacked1" name="radio-stacked" type="radio" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Toggle this custom radio</span>
</label>
<label class="custom-control custom-radio">
<input id="radioStacked2" name="radio-stacked" type="radio" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Or toggle this other custom radio</span>
</label>
</div>

Select Menu

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

<select class="custom-select">
<option selected>Open this select menu</option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>

Multiple selects (e.g., <select multiple>) are not currently supported.

Multiple size are also available.

<select class="custom-select custom-select-xl">
<option>Extra large select</option>
</select>
<select class="custom-select custom-select-lg">
<option>Large select</option>
</select>
<select class="custom-select">
<option>Default select</option>
</select>
<select class="custom-select custom-select-sm">
<option>Small select</option>
</select>
<select class="custom-select custom-select-xs">
<option>Extra small select</option>
</select>

Color Picker

<input type="color"> element need only a custom class, .custom-color to trigger the custom styles.

Browser Compatibility

While Figuration supports styling <input type="color"> elements, some browsers don't. Use custom JavaScript to handle it in these browsers. For support details, see Can I Use.

<input class="custom-color" type="color" value="#117dba" id="color">

File Browser

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

<label class="custom-file">
<input type="file" id="custom-file-1" class="custom-file-input">
<span class="custom-file-control"></span>
</label>

Here's how it works:

  • We wrap the <input> in a <label> so the custom control properly triggers the file browser.
  • We hide the default file <input> via opacity.
  • We use ::after to generate a custom background and directive (Choose file...).
  • We use ::before to generate and position the Browse button.
  • We declare a height on the <input> for proper spacing for surrounding content.

In other words, it's an entirely custom element, all generated via CSS.

Translating or Customizing the Strings

The :lang() pseudo-class is used to allow for easy translation of the "Browse" and "Choose file..." text into other languages. Simply override or add entries to the $custom-file-text SCSS variable with the relevant language tag and localized strings. The English strings can be customized the same way. For example, here's how one might add a Spanish translation (Spanish's language code is es):

$custom-file-text: (
placeholder: (
en: "Choose file...",
es: "Seleccionar archivo..."
),
button-label: (
en: "Browse",
es: "Navegar"
)
);

You'll need to set the language of your document (or subtree thereof) correctly in order for the correct text to be shown. This can be done using the lang attribute or the Content-Language HTTP header, among other methods.

<label class="custom-file" lang="es">
<input type="file" id="custom-file-2" class="custom-file-input">
<span class="custom-file-control"></span>
</label>