Components Text fields

Text fields

Text fields allow users to input, edit, and select text.

Text fields typically reside in forms but can appear in other places, like dialog boxes and search.

Usage

Text fields validate input, help users fix errors, autocomplete words, and provide suggestions.

Field types

Single-line
Multi-line
Text area

Input types

Formatted inputs
Nested menus & pickers

Material Design text fields for user input and editing

Principles Expand and collapse content An arrow that points down when collapsed and points up when expanded.

Text fields should have the following characteristics:

Identifiable

Using a tappable touch target, text fields should indicate that users can enter information.

Findable

It should be easy to find a text field among other elements.

Legible

Text fields should indicate their state – whether enabled or disabled, empty or filled, valid or invalid – with clear label, input, and assistive text.

Layout Expand and collapse content An arrow that points down when collapsed and points up when expanded.

Text fields contain the following elements:

Label

Text field labels display the type of input a field requires. Every text field should have a label.

Labels are aligned with the input line and always visible. They can be resting (when a field is inactive and empty) or floating.

Material Design resting label text

Resting label text
Top padding: 16dp
Bottom padding: 8dp

Material Design floating label text

Floating label text
Top padding above label: 16dp
Bottom padding below label: 8dp
Bottom padding below input: 8dp

Input line

The input line indicates where to enter text, displayed below the label.

When a field is active or contains an error, the line’s color and thickness vary.

Material Design: Labels above line when text field is empty

Labels rest above the line when the text field is empty.

Material Design: Labels float when input is focused or filled

Labels float upward when the text field is in focus or filled.

Cursor

The cursor indicates the user’s current input position.

Cursor inset with label until user input in Material Design

The cursor is inset with the label until the user enters input.

Input text

Text entered into a text field is called input text.

The first letter of input text (and each sentence in a field) should be capitalized where appropriate. Such as text that:

  • Names something, like an alarm
  • Contains phrases, like a text message
Active input field design in Material Design

Input text in an active field

Material Design input text

Input text
Top padding: 8dp
Bottom padding: 8dp

Input text can be used with autocomplete to help users who have limited literacy or who write in a foreign language. For example, autocomplete can:

  • Suggest input as it’s typed (refreshing suggestions with each keystroke)
  • Fill a field with default input text

Pressing the return button accepts the current autocomplete suggestion.

Reduce opacity of suggested text in Material Design

Reduce the opacity of suggested text, while keeping typed text at full opacity.

Placeholder text (Hint text)

Placeholder text rests in the input field until the user starts entering text. It may contain an action or an example, such as a phone number or email address.

Material Design placeholder text for empty fields

Placeholder text can be displayed in an empty text field until input is entered.

Material Design placeholder text

Placeholder text
Padding above label: 16dp
Padding above placeholder text: 8dp
Padding below placeholder text: 8dp

Helper text

Helper text gives context about a field’s input, such as how the input will be used.

It should be visible either persistently or only on focus.

Specs:

  • Left justified
  • On a single line if possible, or with text wrapping (if multiple lines)
Helper text for context below text fields in Material Design

Helper text can provide additional context below the text field.

Material Design helper text

Helper text
Padding above helper text: 8dp

Material Design helper text guides user with placeholders

Helper text can support placeholder text in guiding the user.

Error message

When input isn’t accepted, text fields can display an error message below the input line, with instructions on how to fix the error. Until the error is fixed, the error replaces the helper text.

An error message should appear on a single line, if possible.

Material Design error message guiding user to fix input

An error message helps guide the user to fix invalid input.

Material Design error message

Error message
Padding above the error message: 8dp

An error message is preceded by the word “Error” (or an error icon) to make the error state more distinct to colorblind users.

Error message in Material Design format

The term “Error:” (including the colon) precedes the error message

Material Design error icon with message

Error icon inline with the error message

Required field

To indicate that a field is required, display an asterisk (*) next to its label. At the bottom of the form, mention that asterisks indicate required fields.

Material Design: Required asterisk in empty field

Required asterisk indicator in an empty text field

Material Design: Required asterisk in filled text field

Required asterisk indicator in a filled text field.

To indicate that a field is optional, display the word “optional” in parentheses next to the field label.

Optional indicator text for empty field in Material Design

Optional indicator text in an empty text field

Material Design optional indicator text in text field

Optional indicator text in a filled text field

In forms with some required fields, indicate all of the required ones. However, if there are fewer optional fields, indicate those instead.

Material Design form with required name and zip code

Name and zip code are the only required fields in the form.

Optional description field in Material Design form

Description is the only optional field in the form.

Character or word counter

Use character or word counters where there is a character or word limit.

Specs:

  • Right justified
  • Displayed as a ratio of characters used and the character limit (formatted as: characters used / character limit)
Material Design: 5 of 10 characters entered

The character counter shows that 5 out of 10 possible characters have been entered.

Material Design character counter

Character counter
Padding below the text input line: 8dp

Icon signifier

Icons describe the type of input a text field requires. They are displayed to the left of the text field.

Icons can also be touch targets for nested components. For example, a calendar icon may be tapped to reveal a date picker.

Calendar icon for date entry in Material Design

A calendar icon indicates that the text field is for entering a date.

Material Design icon signifier

Icon signifier
Width: 24dp
Padding between icon signifier and label: 16dp

Voice input icon

A microphone icon signifies that users can input characters using voice.

Voice input icons are right justified, and always enabled.

Voice input icon for Material Design users

Clicking on the icon allows users to input characters using voice.

Voice input icon for Material Design

Voice input icon
Width: 24dp
Padding below icon: 8dp

Dropdown icon

A dropdown arrow indicates that a text field contains nested selections.

Material Design dropdown expands nested selection component

Clicking on the dropdown arrow expands the nested selection component.

Material Design dropdown arrow container

Dropdown arrow container
Width: 24dp
Height: 24dp
Padding below icon: 8dp

Clear button

Clear buttons let users empty an entire input field.

They are right justified in the field.

Clear icon appears with characters in Material Design

The clear icon is enabled when there are characters entered in the field.

Clear icon in Material Design

Clear icon
Width: 24dp
Height: 24dp
Padding below icon: 8dp

In forms with many or crowded fields, text fields may be made shorter.

Specs:

  • Input text: 13sp
  • Reduce space between the label and input text
  • Reduce space between the input line and help text by 50%
Normal spacing in Material Design

Normal spacing
Padding above label: 16dp
Padding below label: 8dp
Padding above text input line: 8dp
Padding below text input line: 8dp

Dense spacing in Material Design

Dense spacing
Padding above label: 8dp
Padding below label: 4dp
Padding above text input line: 8dp
Padding below text input line: 4dp

States Expand and collapse content An arrow that points down when collapsed and points up when expanded.

Text fields have two major states: enabled or disabled.

In the enabled state, these user interactions are available:

  • Idle
  • Hover
  • Pressed
  • Focused

Text field input can be either:

  • Empty or filled
  • Valid or invalid
Text field states in Material Design light and dark themes

Text field states in light and dark themes

Text field states

Enabled

Enabled text fields are empty by default.

Specs

  • Labels have 8dp of padding above the input line
  • Label text is the same size as input text

Accessibility

The line should have a 3:1 contrast ratio to improve identifiability, the same AA accessibility standard as large text.

Material Design light theme enabled text field

Light theme

Bottom line

  • Thickness: 1dp
  • Color: 42% black (3:1 contrast ratio)

Label text

  • Type: Roboto 16sp
  • Color: 54% black (4.5:1 contrast ratio)
  • Spacing: 16dp top padding, 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 54% black (4.5:1 contrast ratio)
  • Spacing: 16dp left padding, 8dp top padding
Material Design dark theme enabled text field

Dark theme

Bottom line

  • Thickness: 1dp
  • Color: 70% white (7:1 contrast ratio)

Label text

  • Type: Roboto 16sp
  • Color: 70% white (7:1 contrast ratio)
  • Spacing: 16dp top padding, 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 70% white (7:1 contrast ratio)
  • Spacing: 16dp left padding, 8dp top padding

Disabled

Disabled text fields are uneditable. They have a dotted input line and less opacity so that they appear less tappable.

Material Design light theme disabled text field

Light theme

Bottom line

  • Thickness: 1dp
  • Color: 42% black
  • Dotted

Label text

  • Type: Roboto 12sp
  • Color: 38% black (2.21:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Input text

  • Type: Roboto 16sp
  • Color: 38% black (2.21:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line
Material Design dark theme disabled text field

Dark theme

Bottom line

  • Thickness: 1dp
  • Color: 70% white
  • Dotted

Label text

  • Type: Roboto 12sp
  • Color: 50% white (4.5:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Input text

  • Type: Roboto 16sp
  • Color: 50% white (4.5:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line

User interactions

Hover

Hover states give the input line more opacity, helping make text fields more noticeable on desktop.

Light theme

Bottom line

  • Thickness: 2dp
  • Color: 87% black (15:1 contrast ratio)

Label text

  • Type: Roboto 16sp
  • Color: 54% black (4.5:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 54% black (4.5:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line

Dark theme

Bottom line

  • Thickness: 2dp
  • Color: 100% white (13:1 contrast ratio)

Label text

  • Type: Roboto 16sp
  • Color: 70% white (7:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 70% white (7:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line

Press

Upon press, the text field label shrinks and floats above the field, revealing the cursor and any placeholder text.

To signal that the field is active, the primary color of the UI is applied to the input line, label text, and cursor.

Light theme

Bottom line

  • Thickness: 2dp
  • Color: 100% primary color (Dark A700)
  • Motion: Ripple & wash

Label text

  • Type: Roboto 12sp
  • Color: 87% primary color (Dark A700)
  • Spacing: 8dp bottom padding, inset with bottom line

Placeholder text (optional)

  • Type: Roboto 16sp
  • Color: 42% black (3:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 54% black (4.5:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line

Dark theme

Bottom line

  • Thickness: 2dp
  • Color: 100% primary color (Light A200)
  • Motion: Ripple & wash

Label text

  • Type: Roboto 12sp
  • Color: 100% primary color (Light A200)
  • Spacing: 8dp bottom padding, inset with bottom line

Placeholder text (optional)

  • Type: Roboto 16sp
  • Color: 50% white (4.5:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 70% white (7:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line

Focus

As the user types into the text field, input text replaces any placeholder text. Autocompleted text is displayed to the right of the cursor, using the same font size and color as placeholder text.

Material Design light theme focused text field

Light theme

Bottom line

  • Thickness: 2dp
  • Color: 100% primary color (Dark A700)

Label text

  • Type: Roboto 12sp
  • Color: 87% primary color (Dark A700)
  • Spacing: 16dp top padding and 8dp bottom padding

Input text

  • Type: Roboto 16sp
  • Color: 87% black (15:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 54% black (4.5:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line

Dark theme

Bottom line

  • Thickness: 2dp
  • Color: 100% primary color (Light A200)

Label text

  • Type: Roboto 12sp
  • Color: 100% primary color (Light A200)
  • Spacing: 16dp top padding and 8dp bottom padding

Input text

  • Type: Roboto 16sp
  • Color: 100% white (13:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 70% white (7:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line

Text field input

Idle & filled

When the user shifts focus to another element, entered input text remains visible.

Material Design light theme text field

Light theme

Bottom line

  • Thickness: 1dp
  • Color: 42% black (3:1 contrast ratio)

Label text

  • Type: Roboto 12sp
  • Color: 54% black (4.5:1 contrast ratio)
  • Spacing: 16dp top padding and 8dp bottom padding

Input text

  • Type: Roboto 16sp
  • Color: 87% black (15:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 54% black (4.5:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line
Material Design dark theme text field

Dark theme

Bottom line

  • Thickness: 1dp
  • Color: 70% white (7:1 contrast ratio)

Label text

  • Type: Roboto 12sp
  • Color: 70% white (7:1 contrast ratio)
  • Spacing: 16dp top padding and 8dp bottom padding

Input text

  • Type: Roboto 16sp
  • Color: 100% white (13:1 contrast ratio)
  • Spacing: 8dp bottom padding, inset with bottom line

Helper text (optional)

  • Type: Roboto 12sp
  • Color: 70% white (7:1 contrast ratio)
  • Spacing: 8dp top padding, inset with bottom line

Text field content

Error

If a text field is invalid, an error message is displayed when the user shifts focus to another element. To indicate an error, the input line and label use a color with a warmer hue, such as red or orange.

Specs

  • Display an error message below the text field, replacing any helper text
  • Briefly state the reason for the error and how to fix it
  • Place the word “Error” (or an error icon) before the error message
  • Remove the error once fixed by the user
Material Design light theme error text field

Light theme

Bottom line

  • Thickness: 2dp
  • Color: 100% red (A400)

Label text

  • Type: Roboto 12sp
  • Color: 100% red (A400)
  • Spacing: 16dp top padding and 8dp bottom padding, inset with bottom line

Input text

  • Type: Roboto 16sp
  • Color: 87% black (15:1 contrast ratio)
  • Spacing: 16dp left padding, 8dp bottom padding

Error text

  • Type: Roboto 12sp
  • Color: 87% red (A400)
  • Spacing: 8dp top padding, inset with bottom line

Dark theme

Bottom line

  • Thickness: 2dp
  • Color: 100% red (A400)

Label text

  • Type: Roboto 12sp
  • Color: 100% red (A400)
  • Spacing: 16dp top padding and 8dp bottom padding, inset with bottom line

Input text

  • Type: Roboto 16sp
  • Color: 100% white (13:1 contrast ratio)
  • Spacing: 16dp left padding, 8dp bottom padding

Error text

  • Type: Roboto 12sp
  • Color: 100% red (A400)
  • Spacing: 8dp top padding, inset with bottom line

Field types Expand and collapse content An arrow that points down when collapsed and points up when expanded.

There are several types of text fields:

  • Single-line
  • Multi-line
  • Text area

Single-line fields

When the text entered is longer than the input line, it automatically scrolls left as the cursor reaches the right edge of the field.

Input text scrolls to the left as the cursor reaches the right end of the single-line text field.

Single-line text fields in Material Design

Single-line text fields

Single-line text fields in Material Design

Single-line text fields

Multi-line fields

Multi-line text fields wrap text onto a new line by expanding the bottom of the field, shifting screen elements downward.

Multi-line text fields allow users to see everything they input at once.

Input text wraps to a new line and makes the field taller as the cursor reaches the right end of the field.

Material Design multi-line text field

Multi-line text field

Material Design multi-line text field

Multi-line text field

Text area

Text areas are taller than text fields and wrap overflow text onto a new line. They scroll vertically when the cursor reaches the bottom of the field.

Input text scrolls up as the cursor reaches the bottom right of the text area.

Message box text area in Material Design

The message box is the text area

Message box text area in Material Design

The message box is the text area

Text areas should have a visible border, using the same color and thickness as the input line.

Material Design light and dark text area states

Light and dark states for text areas

Input types Expand and collapse content An arrow that points down when collapsed and points up when expanded.

Formatted inputs

Text fields can be formatted to indicate the types of data a field accepts, using placeholder text, preset layout, and character limits. Text formatting should be displayed only when the field is pressed, focused, or filled.

Characters can be formatted using:

  • Grouped characters
  • Prefixes and suffixes
  • Password redaction

Grouped characters

Input text can be grouped in different ways, with special characters added in appropriate places, such as hyphens added to a phone number. Once the first special character is reached, the cursor automatically jumps to the next group.

Material Design phone number formatting

Input text grouped and formatted for a phone number

Material Design: Grouped and formatted credit card number

Input text grouped and formatted for a credit card number

Prefixes & suffixes

Prefixes and suffixes can be used to clarify units or to add input in advance. Prefixes are left justified in the text field; suffixes are right justified. Text fields can have both prefixes and suffixes.

Material Design text field prefix for dollar currency

Prefix for dollar currency

Material Design text field suffix for weight

Suffix for weight

Material Design text field suffix for email domain

Suffix for email domain

Material Design text field suffix for time zone

Suffix for time zone

Password redaction

Password input is disguised by default. Midline ellipses are displayed to represent each character of a password entered (such as •••••••).

When the visibility icon is displayed with a text field, it indicates whether or not that field’s input is visible. A text field’s visibility may be toggled on or off using the icon.

Material Design visibility icon shows password characters

The visibility icon is displayed with password characters visible when visibility is enabled.

Invisibility icon for hidden password in Material Design

The invisibility icon is displayed with password characters hidden when visibility is disabled.

Other inputs

Menus and pickers

Other components such as dropdown menus and pickers can be nested in text fields to make input easier.

Material Design dropdown for selecting US state

Text field dropdown menu for selecting a US state

Material Design date picker text field

Text field picker for selecting a date

Field variations Expand and collapse content An arrow that points down when collapsed and points up when expanded.

Draw additional focus to text fields using these style variations:

  • Labels as headings
  • Solo fields
  • Full-width fields

Labels as headings

When a text field is the primary action on a screen, its label can be removed or become a heading.

Placeholder text appears in the idle state and is replaced with input text as the user enters text.

Material Design removes label from field for onboarding

Label text can be removed from the field and displayed as a headline in onboarding or query flows.

Material Design: Use headline instead of label text

Label text can be removed from the field and displayed as a headline in dialogs.

Solo fields

When a text field is used for a single action such as search, the text field may be elevated, with associated icons placed within it. An input line is not required.

On desktop, a raised search button should appear to the right of the search field.

Material Design search action as a raised text field

Search action as a raised text field on desktop

Material Design search action as raised text field

Search action as a raised text field on mobile

App bar as text input field in Material Design

The app bar acts as a text input field

Material Design app bar with nested text input field

The app bar has a nested text input field

Full-width field

Full-width text fields are useful for in-depth tasks or entering complex information.

Material Design full-width text field

Full-width text field

Material Design full-width text field, single/multi-line

Full-width text field with both single-line and multi-line text behavior

Material Design full-width field with normal spacing

Full-width field with normal spacing
Height: 56dp
Top padding: 20dp
Bottom padding: 20dp

Material Design full-width field with dense spacing

Full-width field with dense spacing
Height: 48dp
Top padding: 16dp
Bottom padding: 16dp

Text field boxes Expand and collapse content An arrow that points down when collapsed and points up when expanded.

Text field boxes increase text field identifiability and scannability by using a transparent rectangular fill to enclose the label and input text.

Text field boxes use color to increase the discoverability of the field, while preserving the input line.

States

A text field box uses a rectangular fill as a primary affordance, masking the ends of the input line. A ripple motion occurs in the hover and press states.

Material Design text field states with rectangular shape

Text field states with a rectangular affordance

Rectangular fill

  • Height: 56dp
  • Corner radius: 4dp
  • Color (light theme): 6% black
  • Color (dark theme): 10% white

Bottom line

  • Thickness: 2dp
  • Masked by rounded corners of rectangle

Idle & empty

  • Left padding: 16dp
  • Right padding: 16dp
  • Padding above label: 8dp

Hover

  • Left padding: 16dp
  • Padding above label: 20dp
  • Padding below label: 20dp

Press

  • Padding above label: 8dp
  • Padding below label: 8dp
  • Padding below placeholder: 8dp

Spacing for focus, idle & filled, error, and disabled states are the same as the press state.

Dense layouts

Text field boxes make dense layouts easier to read.

Material Design normal spacing text field

Normal spacing
Height: 56dp
Padding above label: 8dp
Padding below label: 8dp
Padding below text field: 8dp
Padding above helper text: 8dp

Material Design dense spacing text field

Dense spacing
Height: 44dp
Padding above label: 8dp
Padding below label: 4dp
Padding below text field: 8dp
Padding above helper text: 4dp.

Single-line text field box

Text scrolling behavior in a single-line field

Material Design single-line text field with label

Single-line text field with label as heading

Multi-line text field box

Text wrapping and scrolling behavior in a multi-line field

Material Design multi-line field pressed state

Multi-line field in pressed state

Material Design multi-line field: idle and filled

Idle and filled multi-line field

Text box area

Text wrapping and scrolling behavior in the text box area

Empty text area in Material Design

Empty and idle text area

Material Design text area in pressed state

Text area in pressed state

Menus & pickers

Material Design dropdown in rectangular text field

Dropdown list in a rectangular text field

Material Design icon and date picker in text field

Icon and date picker in a rectangular text field