Field
A field puts the label above a form control and the hint or the error under it. Text fields, selects, comboboxes and date fields all sit inside one, so every question on a form reads the same way.
Anatomy
The label says what to enter and stays in view while you type. The hint under the control says what a good answer looks like. When the answer is wrong, the error takes the hint's place and says how to fix it.
- Label
- 13 px on 18 px, weight 500
- --text
- Label to control
- 6 px
- Count
- 11 px, aligned figures, at the end of the label row
- --text-muted
- Control to hint
- 4 px
- --space-1
- Hint
- 12 px on 16 px
- --text-muted
- Error
- 12 px on 16 px
- --error
- Between fields
- 16 px
- --space-4
- Between groups
- 32 px
- --space-8
Required answers
Write it in words: (required) after the label, in the muted ink. An asterisk alone means nothing to someone who does not know the convention. A screen reader announces the field as required.
When all the questions on a form are required, say so once above the first field and mark none of them. A sign in form with an email and a password needs no mark at all.
Errors and warnings
An error stops the form. The field takes a red edge, and a sentence under it says what to enter. The error clears as soon as the answer is right.
A warning lets the form go through. Use it for an answer that is valid but worth a second look.
- Error edge
- 2 px around the control
- --error
- Warning
- 12 px on 16 px
- --warning-ink
Read only and disabled
A read only field shows an answer you can select and copy but not change, such as the ID of a candidate. It has no fill, so it reads as text. It takes focus and is sent with the form.
A disabled field waits for another answer on the form. It fades to 50 percent, Tab skips it and it is not sent. Its hint says what turns it on.
When to check an answer
Check a format when the person leaves the field, and only if they typed something. Check required answers when the form is sent, and show all the errors at once.
Once an error shows, check again on each key, so it clears the moment the answer is right.
Check an answer against the server while the person types, such as an employer that may already be in WerkOS. The hint reads Checking until the answer comes back.
Writing for a field
Write the label as a short noun phrase in sentence case, with no colon or full stop: Date of birth.
Write the hint as one sentence about the answer: its format, where to find it, or why you ask.
Write the error as the fix, in the words of the label: Enter the passport number. Do not tell the person they made a mistake.
Use a placeholder only for an example, and only when the hint does not already give one.
Accessibility
The label element names the control. The error, or the hint when there is no error, is the control's description, so a screen reader reads it after the label.
An error is not announced while someone types. It is read when the field takes focus. After a failed submit, focus moves as the Forms pattern describes. Labels wrap onto a second line and are not cut short.
A field you type in shows focus with a blue ring and a halo. A combobox is a button that opens a list, so it shows focus as a button does, with a blue outline outside its edge.
Permitted and not permitted
Permitted
A label above the control that stays while you type
The person can check the question after answering it.
Not permitted
A placeholder as the only label
It disappears on the first key, and the person has to delete the answer to see the question.