---
url: /components/text-fields/accessibility.md
description: >-
  Text fields let users enter text into a UI. They typically appear in forms and
  dialogs.
---

# Text fields

Text fields let users enter text into a UI. They typically appear in forms and dialogs.

[Overview](overview.md) · [Specs](specs.md) · [Guidelines](guidelines.md) · **Accessibility**

## Use cases

User should be able to:

* Navigate to and activate a text field with assistive technology
* Input information into the text field
* Receive and understand supporting text and error messages
* Navigate to and select interactive icons

## Interaction & style

The containers for both filled and outlined text fields provide the same functionality. Changes to color and thickness of stroke help provide clear visual cues for interaction.

![2 filled text fields in enabled empty state and in focused populated state have visual cues to identify their state.](/assets/addb6d6a-mtsdrr40-01.BM5ij97y.webp)

Filled text fields

![2 outlined text fields in enabled empty state and in focused populated state have visual cues to identify their state.](/assets/819f5222-mtsdstko-02.Bz756qat.webp)

Outlined text fields

Containers improve the discoverability of text fields by creating contrast between the text field and surrounding content. <br><br>In some contexts, outlined text fields can improve the perception of the fields with a 3:1 or greater contrast ratio between the container outline and the background.<br>

::: tip Do
![An outlined text field with label text that passes the minimum contrast of 3:1.](/assets/4df99eb0-lx32k7wf-3.y2sbVRuz.webp)

Make sure the container outline has a minimum contrast of 3:1 to the background<br>

<br>
:::

::: danger Don't
![An outlined text field with label text fails the minimum 3:1 contrast.](/assets/62e1d0f7-lx32kef6-4.fj2j7m_M.webp)

Don't choose colors that won't pass Material's minimum contrast of 3:1
:::

## Keyboard navigation

| Keys | Actions                                  |
| :--- | ---------------------------------------- |
| Tab  | Focus lands on (non-disabled) text field |

## Labeling elements

If the UI text is correctly linked, assistive tech (such as a screenreader) will read the UI text followed by the component’s role.<br><br>The [accessibility](../../foundations/overview/principles.md "Accessible design makes products usable for people with all kinds of abilities.") label for a text field is the same as the text field label.

![The text field and accessibility label both read “Email.” The role is “textbox.”](/assets/b6fda1af-lx32ks8b-5.BWKUv-PV.webp)

A text field’s label should include its UI text

For text fields with interactive trailing icons, the accessibility label clarifies its function.

For example, when a password is hidden, the label for the view icon is "Show password," and when the password is visible, the label is "Hide password."<br><br>When an icon has no actionable role, like an error icon, the label is "Error."

![The trailing icon’s accessibility label “Show Password.” The role is “Button.”](/assets/bc236093-lx32l5y8-6.DhGtviFj.webp)

When a trailing icon in the field acts as a button, the label should clarify function, while the role explains the component type

The prefix and suffix of a text field provides symbols and abbreviations to help users enter the correct values. <br> <br>The [accessibility](../../foundations/overview/principles.md "Accessible design makes products usable for people with all kinds of abilities.") label for prefix and suffix needs to have a unique id attribute, for example, the currency name for a currency symbol prefix.

![Text field accessibility labels “UI text” are “Euro” for a currency prefix and “At gmail dot com” for the email address suffix.](/assets/2a73c1a5-lx32leg0-7.D8lczNds.webp)

A form containing fields with both a prefix for currency, and a suffix for email address

When there is an error, "alert" is applied to the role and the error message to the text label.

If a text field displays both supporting text and error text, the label should include the supporting text first, followed by the error text.

![The text field accessibility labels is: UI text “Not a valid ZIP code.” The role is “Alert.”](/assets/de7f72b9-lx32lojq-8.Dv9hK8Q8.webp)

Text field error messages should be given an “alert” role in accessibility labels

The accessibility label for the character counter clarifies the number of characters that can be entered into the text field.

![A character counter's accessibility label reads: UI text (“Character count, 5/20”)](/assets/d4bcb365-lx32m4pa-9.B6HegvtA.webp)

The remaining character counter should be called “character count” within the label

The text displayed in the supporting text is also used for its accessibility label.

![The accessibility label uses the supporting text. It reads: UI text (“Please use the company email address”). Role \[No role\].](/assets/55c77f35-lx32meu7-10.CeWfkItF.webp)

Text field supporting text should have its own accessibility label

If a text field requires input, indicate so with an asterisk at the end of the text field label. The accessibility label must include the asterisk.

![Accessibility label reads: UI text (“Username\*”). The role is “Textbox.”](/assets/43862daa-lx32mlzg-11.DItkyNiw.webp)

A required text field’s accessibility label should include any supporting text
