Text field
A text field takes one line of text: a name, an email address, a passport number, an hourly rate. It sits inside a Field, which gives it a label, a hint and an error.
When to use it
Use a text field when the person has to type the answer. If the answers are known in advance, let them choose: radio buttons for up to five, a select or a combobox for more. For more than one line, use a text area.
Size the field to the answer. A year or a postal code gets a short field. A name or an email address takes the width of the form.
Anatomy
In the light theme the field is a soft grey well, with no line and no shadow. In the dark theme it is a faint white fill with a thin ring inside its edge. The fill shows where to type, and the label above says what.
- Height, medium
- 44 px
- Height, large
- 48 px
- Corner radius
- 8 px
- --radius-lg
- Side padding
- 12 px
- --space-3
- Text
- 14 px on 20 px
- --text
- Text on a touch screen
- 16 px on 22 px
- --text
- Fill in light
- ink at 5 percent, no line, no shadow
- Fill in dark
- white at 4 percent, a 1 px ring inside the edge
- --input-border
- Placeholder
- 14 px on 20 px
- --text-muted
- Leading icon
- 16 px, text starts at 36 px
- --text-muted
- Trailing button
- 32 px, 6 px from the end
Sizes
Medium fits most forms. Large is for a page whose only task is the form, such as the intake form a candidate fills in.
On a touch screen the text grows to 16 px so the browser does not zoom into the field. The field keeps its height, and the page can still be zoomed.
States
Focus turns the field white in the light theme and puts a blue ring around it. The pointer changes nothing: a field looks the same under the mouse as at rest.
Rest
Focus
Error
Read only
Disabled
- Rest
- The fill, and in dark the inner ring
- Focus
- a white fill in light, a 1 px inner ring of the brand blue and a 3 px halo (4 px in dark)
- --brand-blue
- Error
- A 2 px red edge
- --error
- Read only
- No fill, full ink
- --text
- Disabled
- The field fades to 50 percent
Keyboards and autofill
Set the input type so a phone shows the right keyboard: email for addresses, tel for phone numbers, url for links, and the decimal keyboard for amounts.
Name the answer for autofill with a standard token such as name, email, tel or organization. Turn autofill off only where the field holds no personal data, such as a filter. An autofilled field keeps its own fill.
A password field has a Show button at its end. It reveals the text and becomes Hide. Never fill in a password in advance.
Amounts and signed numbers
Accept what people type and paste: a comma or a point for decimals, spaces between thousands, and a minus for a value below zero. When the person leaves the field, show the number in their format with aligned figures. Write the unit after the field, such as EUR or hours.
Accessibility
The field takes its name from the Field label. A field with no visible label, such as a search in a toolbar, carries the same words as its accessible name.
On a touch screen the field is at least 44 px high, and the page never locks zoom.
Permitted and not permitted
Permitted
A text input with the decimal keyboard for an amount
Typing, pasting and a decimal comma all work.
Not permitted
A number input with arrows for an amount
A scroll wheel over the field changes the value without anyone noticing.