A styled text input field.
Text fields are the most common form control type to accept user input. They are primarily used for short, freeform text. There are Pluma components similar to the TextField that also accept freeform text, so it's important to understand the key differences to make the most appropriate choice.
While not explicitly required, we highly recommend providing a visible label so users understand the purpose of the TextField at a glance. If visible labels aren't possible or needed, be sure to provide an accessible label.
For more information on placeholders and accessibility, see Placeholders under the Accessibility tab.
The default TextField is most suitable for names, emails, and other short-form text.
Password fields mask user input by default and include a toggle button to unmask and mask as needed.
In adhering with Pluma's focus on flexibility, the TextField component includes customization options beyond plain text. Customization is useful for adding richer label content or building custom assistive text.
Descriptions are assistive text that display below the field. They can accept rich content including links.
A description with an inline link directs users to additional resources.
The label accepts rich content, allowing you to include supplementary elements such as icons or optional indicators alongside the label text.
Icons can be used to reinforce the label's meaning.
Supplementary text clarifies that the field is not required.
Error messages are assistive text that display below the field. They accept rich content, allowing you to include links or formatted text that better help users resolve the issue.
An error message with a link directs users to relevant documentation or support.
TextFields are available in two sizes: medium and small. Medium is the default.
Medium is suitable for most use cases.
Small is suitable for dense layouts and smaller viewports.
An icon can be used to emphasize visual meaning of the TextField, such as denoting search functionality.
Leading icons are displayed to the left of the field text.
The TextField has default input styling in its base resting state.
Border color updates on mouse hover to signal the field is interactive.
On keyboard focus, the field receives the standard 2px focus ring and the border color updates.
Active styles apply when the user interacts with the field.
Disabled fields cannot be interacted with. Background and text color update to indicate the field is unavailable.
A spinner displays inside the field to indicate a background job is in progress.
The TextField adopts danger styling to indicate there's an error. An error message displays below the field when set.
A clear button can be enabled to reset the field to its initial empty state. The button is hidden when the field is empty.
The clear button resets the field.
Password fields include a toggle icon to unmask or mask user input. The toggle icon updates to reflect the current visibility state.
Password characters are masked by default.
Assistive text displays below the TextField and gives the user information about the form field they're interacting with. Assistive text comes in different forms including descriptions and error text.
Use description text to provide hints, formatting guidance, or constraints that help users enter the correct data. Short, complete sentences are preferred.
Frame validation errors as direct instructions, not accusations. Never use "Please".
Write clear, concise labels that describe the data the TextField expects. Nouns and noun phrases are preferred.
Placeholders help the user complete a field by describing what information it expects or how it should be formatted. For most TextField use cases, we recommend leaving the placeholder empty. A blank field is easier for a user to see that it must be filled before submission.
e.g. for example values