UI ELEMENTS
Form building nightmare made easy.
Forms are a tough thing to implement, especially if you want to include them in a fluid layout, so we made everything work as painlessly as possible while giving you multiple layout choices as you build your forms.
Please note that forms, like other components in Ink, use the grid css classes to create form layouts. So if you haven't looked at the grid documentation yet, we suggest that you give it a read.
Class name | Description |
---|---|
ink-form |
The form root class. |
control-group |
Defines the container for a label / form control pair. Used with a <div> element. |
control |
Defines the container for a form control (e.g. text field, checkbox, etc.). Used with a <div> element nested in the .control-group.
|
required |
Defines a required field. |
validation |
Used if you need to print a message upon form submission. |
error warning
|
Defines the type of message printed upon form submission. |
tip
|
Defines the default ink style for a tip. Used with a paragraph in the form. |
This is the most straight forward type of form, since all of its elements are displayed on top of each other, as a block.
Example
These form elements are displayed in blocks (labels over fields), but each control group is inline with the previous. For this, Ink lets you use layout classes to build different form field layouts.
Note that the control-group
elements are wrapped in a <div>
instead of a <fieldset>
. This is only required if you're using a flexgrid. The reason for this is that the <fieldset>
, such as other form elements, don't recognise the display:flex
property, so you need to use one that does.
Example
To make inline forms, Ink makes use of its grid structure to build them for various layouts and screen sizes.
Example
Example
Ink forms also has utility classes to address and highlight warnings and required fields. So if you have a required field, generated content will be added to mark your field as required, this way you don't need to do it manually.
Adding tips to forms fields is easy. Just add the message by using a paragraph element with the tip
class and keep it inside your control-group
.
Example
A required field has a red asterisk () indicating that it is mandatory to fill it.
To make a required field, add the required
class to its control group.
Example
Example
To mark a field as an errored field, just add the validation error
CSS classes to your control group. The field will have a red border, and tip text will become red as well.
Example
Case you need to append or prepend buttons or symbols to your form input, Ink has got that covered aswell. To achieve that, and depending on your use case, just add the class append-button
, prepend-button
, append-symbol
or prepend-symbol
to the control
element and wrap your <input>
in a <span>
.
Example
Example