Forms
A form asks a person for what WerkOS cannot work out itself. Ask for less, in the order people think about it, and say exactly what to fix.
Before you ask
Take what WerkOS already knows from the record, the account or the step before, and ask only for the rest.
Fill in a sensible default. Offer a choice when the answers are known. Leave typing for what only the person can say.
Layout
Use one column with labels above the fields. Put two fields on one row only when people read them as a pair, such as passport number and expiry, or start and end date. On a narrow screen they stack.
Group related questions under a short heading, and order the groups the way people think about the task.
- Column width
- At most 768 px
- Between fields
- 16 px
- --space-4
- Between groups
- 32 px
- --space-8
- Pairs stack below
- 640 px
- Buttons below 640 px
- Full width, stacked, the main action on top
Checking answers
Check a format when the person leaves a field they filled in. Check required answers when the form is sent, and show all the errors at once.
In a form that fits the window, focus then moves to the first field with an error. In a longer form, a message above the first field says how many answers need a change, links to each, and takes the focus.
Sending
Name the button after what it does: Add candidate, Save changes, Send offer. While the form is sending, the button stops taking presses and shows a spinner once sending takes longer than a second. The answers stay as they are.
If sending fails, keep the answers, put a message above the first field that says what happened, and move focus to it. When it succeeds, show the new record where the person expects to find it.
Enter in a field sends the form, and so does Cmd+Enter or Ctrl+Enter in a text area. In a dialog, Escape closes the form, and asks first when answers are unsent.
The candidate was not saved. Check your connection and try again.
Saving as you go
A form with a send button saves nothing until it is sent. A settings panel saves each change on its own and says Saved beside it. Keep the two apart on one screen.
When someone closes a form with answers they have not sent, ask first: Discard changes? with the buttons Discard and Keep editing.
On a phone with the keyboard open
On a phone, a form that opens in a dialog becomes a sheet as tall as the part of the window the keyboard leaves free. The questions scroll, and the buttons stay at the bottom of the sheet, above the keyboard.
The field you are typing in scrolls into view above the buttons. Text in fields stays at 16 px so the browser does not zoom, and the page can still be zoomed by hand.
Add candidate
Permitted and not permitted
Permitted
An enabled send button that checks the form and shows what is missing
Focus lands on the first answer to fix.
Not permitted
A send button disabled until the form is complete
Nothing says which answer is missing, so the reader has to hunt for it.