Form pattern
Forms are at the core of Gusto’s products. Use these guidelines to create forms that are predictable, easy to use and cohesive across the platform.
-
Spacing in forms follow a consistent pattern of
12px
between unique elements and8px
between grouped elements (like radios and checkboxes). -
There are subtle differences between elements with a description (
0px
between title and description,4px
between the description and form element) elements with just a label (4px
between the label and form element)
The default styles for Input
, Textarea
, Select
, Autocomplete
components are: salt-300
as the background color, salt-1000
text, and a 2px salt-700
bottom border.
The focus state styles for Input
, Textarea
, Select
, Autocomplete
components are: kale-100
as the background color, salt-1000
text, and a 2px kale-500
bottom border.
The error state styles for Input
and Textarea
components are: error-100
as the background color, salt-1000
text, and a 2px error-500
bottom border. Error message text should always appear below the field and be set to error-500
Success message text should always appear below the field and be set to kale-500
. This state should only be used for async form behavior (e.g. requiring validation from a third party service before the form is submitted)
Learn more about disabled states on our Accessibility page.
Since most form fields in Gusto’s platform are required, only optional fields should be denoted. This pattern reduces the amount of information presented to users, making forms easier to complete.
A checkbox can also have an indeterminate state when its value cannot be expressed with a binary true
or false
value. This state is most often used on groups of checkboxes that contain "children" elements, which can
have different values.
Forms are easiest when building with Formik
. To use our components with Formik wrappers, make sure to import from @gusto/workbench-formik
. These components work exactly the same as their @gusto/workbench
counterparts, but with the added benefit of having state management handled by Formik
.
Learn more about implementing forms »
Use validation text to confirm that the input meets key criteria for that specific field—the input may have been checked against a database (like tying a routing number to a bank) or validated for certain characteristics (like making sure that a password has a certain number of characters). Here are some do’s and don’ts: