The Core style set lets you easily construct forms that follow the standard form layout and design.
Note: This documentation assumes that you have an understanding of how HTML forms work. It will not go into detail
as to how forms are constructed, but rather explain the specifics of the Core-related form styles.
If you want to build a standard form, you will need to apply the class form to your form element.
Form Themes
Appliy a form theme with the form-theme-* class
on the form element. Currently, only form-theme-standard is available.
With no specific theme defined, your form will have a transparent background.
Standard Form Theme
This is the standard form theme.
Form Structure
Forms are structured using the grid(-flex) layout. To make inputs 100% wide, use one-whole.
Form Elements
There are standard definitions for all common form elements. The sections below will show examples of each.
Text Inputs
All text inputs get the class input-text. Additionally, each input should have a label that helps the user understand which input is asked from them. labels should contain a word or two only. If you need to give additional explanation, use input-label-helper-text. input-label-helper-text needs to be put after the input for correct alignment. Wrap text inputs in a surrounding input-text-container.
You can attach icons to your text inputs to give the user an additional hint about what is asked of her.
To apply an icon, insert a FontAwesome icon inside the container, using input-icon-left or input-icon-right accordingly. Make sure you put the icons before input-text, otherwise the input field will not have the correct padding.
Select Fields
Select fields get the class select and are wrapped in a select-container element.
Input Controls
Input controls are radio buttons, checkboxes, and toggle switches. For each of these, two styles are available: the default style and the long list style. For each input control, labels are needed to show what the input control refers to.
Inside, apply a class to the input, such as input-checkbox, and for the label a class like label-checkbox.
Default Style
For each input control, use a container element with a corresponding class, i.e. for checkboxes checkbox-container.
use the default style if you have little space or few options
don't use it if there are many selection controls on a page
Make use of the list tag ul, the -list class, i.e. radio-list for radio buttons, and an li item underneath.
List Style
use the list style if you have many choices on a page
the list style gives more overview to users compared to the default style
it clearly differentiates selections from each other through padding and outline
Why is my input control not clickable?
Linking the label and the input control via id and for makes the label area clickable. In our case, this means the whole row can be clicked. In standard HTML without the linking, only the input control itself is clickable. In CoreCSS, an unlinked input control is not clickable at all.
Radio Buttons
Checkboxes
Toggle Switches
Submit Buttons
You can use any of the globally available buttons as form submit buttons. Please see the
Buttons section for more information.
Move buttons around with the float-* classes.
Cancel Link
If you wish to offer a way to cancel the form or go back to a previous step, insert a regular link with the
cancel class alongside your submit button.
Errors
You can highlight faulty input by adding the error class to an input field.
Required and Optional Labels
Mark your optional inputs as optional by adding label-optional to a label. Required inputs will not get a visual designation, stemming from the observation that required inputs are the norm, while optional inputs appear less often.
Disabled Inputs
Please do not use disabled inputs. Make sure all your input fields are usable.
Optimizations for Mobile Users
If possible, make life easier for mobile users by making sure the most appropriate keyboard is shown when they click on an input field and that autocorrect and auto capitalizing is turned off in cases where it is not useful. For example, use type="tel" for phone numbers and type="email" for email addresses. Be careful with type="number", though, since it does not allow alphabetic characters and is therefore not suitable for cases like house numbers. For these cases, it is best to stick with type="text". For more information, follow Apple's "Text Programming Guide for iOS" or this article from treehouse.
Status Messages
If you want a form to give feedback to the user, you may use one of the four status messages.
Please see the Status Messages section for a full description.
HTML5 Validation
The HTML5 Constraint Validation API brings some
powerful (if not yet consistently supported) tools to validate a user's form input on the client side.
We recommend using the Webshims polyfill as a fallback for
legacy browsers who do not natively support the HTML5 Validation API.