Live demo
Demo source
Use a text field for short, single-line input such as a name, an email address or a search term.
Anatomy
A text field with three callouts: 1 marks the label Field label, 2 the input showing the placeholder Input example, and 3 the description below it.
- Label (optional) says what to enter.
- Input holds the text. It fills its container up to 480 px; set
fluidfor wider layouts. An icon or unit can sit inside it, before or after the text. - Description (optional) adds guidance below the input.
States and feedback
Hover and focus styles are built in. A disabled field cannot be used; a
read-only field shows its value without allowing edits. required adds an
asterisk to the label and marks the native input as required.
When the input is invalid, set error with an errorDescription that says how
to fix it: the field shows a red border, an error icon and the message. Once
the input is valid, success shows a green border and a check icon.
Themes
The design includes Spark and Ocean appearances. Use the page's theme and mode controls to compare the live examples; retain the same labels, states and validation messages in each theme.
Guidelines
- Give every field a clear label that names its purpose.
- Keep placeholder text brief. It disappears as people type, so it cannot replace the label or instructions.