Skip to main content

Inputs

Usage

Definition

The input allows a user to type and submit alpha-numeric text. Variations and rules for specific input types are specified below.

Full-screen width fields are only allowed on the XS grid (0-479). In all other cases, inputs should span to a specified number of columns in the layout.

Common Characteristics

Text inputs are normally 40px high, but a small 32px alternative may be used. Whichever size is used, use the same size for associated elements like selects and buttons.

When using text inputs always declare the appropriate HTML input type to ensure that mobile browsers invoke the correct mobile keyboard.

All text inputs have these states: disabled, active, and focused.

Label Options

In some scenarios it may be desired to move or hide the input label. Right aligned labels can save vertical space in the UI. Hidden labels should be used with caution, and only when there are very few fields (e.g. a login form), or where the input required is very well understood (e.g. the user’s street address).

Hidden labels are present in the code but hidden in the UI, allowing screen readers to read the label.

Required vs Optional

When designing forms, aim to include only required fields. Avoid optional fields unless designing a search/filter scenario, where all fields may be optional.

Do not mark required form fields with an asterisk (*). Instead, mark optional fields as “optional” next to the label when they are an exception that can't be avoided. Optionally, designers can include a text instruction, “All fields are required.” at the top of the form.

Optional

Optional fields should be an exception and marked as “Optional”.

Validation

When an input is required, validation should take place as soon as technically possible in the user's experience, beginning with while a field is in focus (e.g. a matching password field), then when a field loses focus (e.g. an email field), etc.

It's all good message
There's a problem message

Inputs requiring a specific number format should allow users to input the format as they wish without triggering a format error. The field should auto-format the displayed entry as the user types and submit the format required by the system. This can be done by ignoring all non-numeric characters entered (parentheses, dashes, dots, etc).

This is not a valid 10-digit phone number.
This is not a valid 10-digit phone number.

Types and Variants

10 characters remaining

Design

States

All text inputs have these states: disabled, active, and focused.

Size

Text inputs are normally 40px high, but a small 32px alternative may be used. Whichever size is used, use the same size for other form elements like dropdowns and buttons.

Full-width inputs are only allowed on the XS grid (0-479). In all other cases, inputs must span to a specified number of columns in the layout.

Disabled

Active

Focus

Validation

It's all good message
There's a problem message

Documentation

CSS

Modifiers that can be used with CSS classes in markup.

ClassProperty
.form-controlSize
.btn-textonlyText-Only Button
.btn-icon-onlyIcon-Only Button
.disabled, :disabledDisabled Styles
.is-invalidapplies danger styles
.is-validapplies success styles
.btn-paginationPagination Button
.font-size-{size}Applies sm or lg Label

Code

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.

Set heights using classes like .form-control-lg and .form-control-sm.

Disabled

Live Editor
Result
Loading...

Active

Live Editor
Result
Loading...

Focus

Live Editor
Result
Loading...

Validation

Live Editor
Result
Loading...

Interactive Input

The Interactive Input contains several addons to the input component. These include icons inside or outside of the input, as well as a password type for login forms.

Live Editor
Result
Loading...

Number Input

Live Editor
Result
Loading...

Textarea Counter

Live Editor
Result
Loading...

Phone Number Input

The Phone Number input can be created in one of two ways: PhoneInput or InteractiveInput

Live Editor
Result
Loading...

Readonly Inputs

Any input component can be made readonly by providing the readonly prop

Live Editor
Result
Loading...

Additionally, the contents of a FormGroup or InputGroup can be made readonly by providing the readonly prop

Live Editor
Result
Loading...
Live Editor
Result
Loading...

Input Props

NameTypeDefaultDescription
autoFocusboolfalseEstablishes the autofocus attr on the input element
childrennodenull
typestring"text"Sets the type of input to display
sizestringlgSets the input size to small (sm) or large (lg)
validboolfalseDisplays the styles for a valid text input
invalidboolfalseDisplays the styles for an invalid text input
tagstring"input"
classNamestring"form-control"Sets a custom class name on the input
plain-textstringnull
placeholderstringnullSets the input placeholder text
disabledboolfalseDisables input and applies disabled styles
readonlyboolfalseApplies readonly state

InteractiveInput Props

NameTypeDefaultDescription
typestring"text"Sets the type of input
minnumber0Sets the minimum number of characters input
iconBeforestringnullDisplays an icon before the input text
onClickBeforefunctionnull
iconLeftstringnull
onClickLeftfunctionnull
iconRightstringnullDisplays an icon before the input text
onClickRightfunctionnull
iconAfterstringnull
onClickAfterfunctionnull
readonlyboolfalseApplies readonly state

Siblings

Label Props

NameTypeDefaultDescription
childrennoderequired
tagstring"label"
classNamestring"form-control"
forstringnull
fontSizesmorlgnull

FormGroup Props

NameTypeDefaultDescription
inlineboolnull
disabledboolfalse
tagstring"div"
readonlyboolfalseApplies readonly state to all children

Variants

NumberInput Props

NameTypeDefaultDescription
labelstringnull
minnumber0
maxnumber10
classNamestringnull
onChangefuncnull
readonlyboolfalseApplies readonly state

PhoneInput Props

NameTypeDefaultDescription
aria-labelstringnull
classNamestringnull
iconbooltrue
labelstringnull
invalidboolfalse
labelstring''
readonlyboolfalseApplies readonly state