Skip to main content
U.S. flag

An official website of the United States government

Dot gov

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

Https

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Components

Text Input

use: best-practice English, Spanish, Tagalog Web
Text Input allows people to enter any type of text unless otherwise restricted.

Examples

Default

View va-text-input in Storybook

Required

View va-text-input Required in Storybook

Pattern

View va-text-input Pattern in Storybook

Valid Range

View va-text-input valid range in Storybook

Autocomplete

View va-text-input Autocomplete in Storybook

Hint Text

View va-text-input with Hint text in Storybook

Also refer to the overall form guidance for hint text examples and usage.

Inline Hint Text

View va-text-input with inline Hint text in Storybook

Details

View va-text-input with Details in Storybook

Character count

View va-text-input with character count in Storybook

Currency

View va-text-input with currency in Storybook

Password

View va-text-input password in Storybook

Forms pattern - Single

View va-text-input forms pattern single in Storybook

Forms pattern - Single error

View va-text-input forms pattern single error in Storybook

Forms pattern - Multiple

View va-text-input forms pattern multiple in Storybook

Error

View va-text-input Error in Storybook

See form error handling for additional guidance.

Success

View va-text-input Success in Storybook

Internationalization

View va-text-input Internationalization in Storybook

Prefix (Icon)

View va-text-input with prefix in Storybook

Suffix (Text)

View va-text-input with suffix in Storybook

Prefix and Suffix

View va-text-input with icon and suffix in Storybook

Widths

View va-text-input widths in Storybook

Usage

Additional guidance for VA

Choosing between variations

  • Required. Indicates to the user that the text input field is required in order to submit the form.
  • Pattern. Allows for a pattern of characters to be required for the text input entry to be valid.
  • Valid range. Allows for a range of numeric values to be required for the text input entry to be valid.
  • Autocomplete. Specifies what if any permission the user agent has to provide automated assistance in filling out form field values, as well as guidance to the browser as to the type of information expected in the field.
  • Hint Text. Provides a short hint to the user on what to enter into the field.
  • Inline Hint Text. Provides a very short hint to the user within the label on what to enter into the field. Hint text is preferred to inline hint text.
  • Details. Depicts how to use the Details component within a va-text-input.
  • Character count. Implements the USWDS Character count functionality which displays the character count below the text input. However, our implementation differs from USWDS in that it does not allow for entering more text after the maxlength.
  • Currency. Indicates that the input accepts a dollar amount.
  • Forms pattern - Single. This variation can be used to support the One thing per page content principle where we gather one decision, question, or piece of information on the page.
  • Forms pattern - Single error. Shows the error state for the single form field pattern.
  • Forms pattern - Multiple . This variation also can be used to support the One thing per page content principle where we gather one decision, question, or piece of information on the page.
  • Error. Highlights the text input field where the user has made an error that needs to be corrected.
  • Success. Indicates to the user in realtime that an error has been cleared and the text entry is now valid. NOTE: This isn’t typically used currently.
  • Internationalization. Demonstrates how this components changes when used with the language toggle.
  • Prefix and Suffix. Allows an icon or text to be set as an input prefix and/or suffix. See USWDS Input Prefix and Suffix for additional guidance.
  • Widths. Indicates to the user the expected length of text input by sizing the field relative to what is expected.
  • Password. Masks the text entered for sensitive information like passwords, PINs, or Security Security numbers. Use for authentication fields and temporary verification codes. Don’t use for phone numbers, or other information that users may need to verify visually. For encrypted file passwords, see File input.

Errors

  • Refer to the specific error examples above.

Hint text

Code usage

Using message-aria-describedby

In HTML, the attribute aria-describedby accepts ids of the elements that describe an object. This is used to establish a relationship between an element and text elsewhere that describes it for screen readers.

However, the VA.gov Design System uses web components and the shadow DOM, which prevents HTML’s aria-describedby from being able to establish the relationship between elements. Because of that, the message-aria-describedby prop is used in our components instead. Instead of accepting ids, it accepts a message string to read out. This message is placed inside the shadow DOM, hidden visually, but made accessible to screen readers. This allows it to function similarly to aria-describedby and have the descriptive text read out when the element is focused.

Native Events

  • Native onInput and onBlur events are available on this component. They can be used by adding the event handler to your component and it will then listen to the event and respond accordingly when the event fires.

Accessibility considerations

Additional accessibility considerations for VA

  • Avoid placeholder text. Excluding our max characters variation (v1), avoid using placeholder text. Most browsers’ default rendering of placeholder text does not provide a high enough contrast ratio. Also, placeholder text is no longer visible once a user clicks into the field. Thus users will no longer have that text available when they need to review their entries. People who have cognitive or visual disabilities have additional problems with placeholder text.

Privacy guidance

An open text field has a high risk for users to enter Personally Identifiable Information (PII) or Protected Health Information (PHI).

  • Responses provided in open text fields should never be tracked in analytics
  • If the responses are utilized in elements on follow-on or related pages—such as an H1—ensure that information isn’t tracked in analytics or passed in URLs

Learn more about PII/PHI on the VA Platform website

Provide feedback

Share your feedback, report issues, or suggest improvements for the Text Input component. Your input helps us make the design system better for everyone.

Edit this page in GitHub (Permissions required)
Last updated: Apr 22, 2026