Explore behaviors before defining the interface.
Quick guide for designers
Always consider the context of the application, even when the guidance follows a standard pattern. Interaction design documents intent. Behavior must be verified in the implementation.
When to use
Use to enter a password, allowing pasting and password managers.
What to draw
Show a persistent label, instructions, focus, errors, and hidden or visible content. The button indicates the next action: Show password or Hide password.
How it behaves
Showing or hiding preserves the value and focus on the button without submitting the form. Do not include the password in messages or announcements.
What to document in Figma
Record rules, messages, whether the purpose is sign-in or password creation, and the button name in each state.
How to review
Check whether the purpose and states are clear on small and large screens and with zoom. Verify documented behavior in the implementation, including keyboard and screen reader use where applicable.
Full guidance
Interaction Design
Questions to ask when designing Input "password" components.
Assess each guideline according to the component's context of use.
Designing for "no interaction"
- Does the label remain visible and explain the field's purpose?
- Are instructions, required status, and limits available before entry?
- Are empty, filled, invalid, disabled, and read-only states distinguishable without relying solely on color?
Designing for mouse use
- Does clicking the field or its associated label focus it for typing?
- Do focus and associated controls provide perceptible visual feedback?
Designing for gesture use
- Does the touch area allow selecting the field and its controls without accidental activation?
- Do the virtual keyboard and zoom allow the field to remain visible and editable?
Designing for keyboard use
TabandShift + Tabmove through controls in interface order?- Can you edit and select text using native commands without trapping focus?
Designing for screen reader use
- Are name, type, required status, instructions, and errors presented understandably?
- Is the label associated with the field and still available after filling it in?
Designing the visibility button
- Is the "Show password" button accessible by mouse, touch, keyboard, and screen reader?
- After showing, does the text change to "Hide password", indicating the next action?
- Does toggling visibility preserve the value and keep focus on the button without submitting the form?
Interaction methods
The password starts hidden and the button displays "Show password".
Mouse interaction
- Clicking the field or its associated label puts focus in the field.
- Selecting, editing, copying, and pasting follow the field's native behavior.
Keyboard interaction
Tabmoves focus to the field;Shift + Tabreturns to the previous control.- Typing inserts text;
arrow keys,Home,Endand selection and editing commands follow the platform. Enterfollows the form's defined submission action; the field does not create a new line.
Gesture interaction
- Tapping the field or label allows editing with the virtual keyboard.
- Text selection and editing follow the platform's available gestures.
Keyboard (or gesture) interaction + screen reader
- When navigating to the field, the reader presents its label and type, along with associated states and instructions.
- Errors are associated with the field and explain how to correct the information; the entered value is preserved.
Show and hide the password
- With the password hidden, clicking, tapping, or pressing
EnterorSpaceon the "Show password" button reveals the content and changes the text to "Hide password". - With the password visible, activating "Hide password" masks the content again and changes the text to "Show password".
- The button has type button, does not submit the form, and keeps focus after activation. The field value is preserved.
- The accessible name follows the text of the next action. In this changing-label pattern, use an action button without aria-pressed. The screen reader should not receive extra announcements containing the password.
Gherkin
BDD (Behavior-Driven Development) methodology focusing on three pillars: User Stories, Acceptance Criteria, and Gherkin Syntax (Given, When, Then).
Scenario: Given that I am on a page containing Input "password"
Keyboard navigation
- WHEN I use the
Tabkey to move focus to the field - The focus I SEE is strongly indicated visually
- THEN, when I type, select, or edit content using native commands
- I SEE the field value updated and characters remaining hidden by default
- AND, when I use
TaborShift + Tab, I SEE focus follow page order without getting trapped in the field
Desktop screen reader
-
WHEN I use a screen reader on a computer (NVDA, JAWS, VoiceOver) and use the
Tabkey to move focus to the field, the following happens:- I HEAR the field's label and purpose.
- I HEAR that the component is a password field.
- I HEAR the required status, instructions, and associated errors, when present.
- I HEAR that entry is protected while the password is hidden, without extra announcements of the password content.
- THEN, when I type or edit content using native commands
- I HEAR or perceive that I can edit the field according to the platform's protected entry behavior, without exposing the password in status messages.
Mobile screen reader
-
WHEN I use a screen reader on a phone (TalkBack, VoiceOver) and swipe to focus the field, the following happens:
- I HEAR the field's label and purpose.
- I HEAR that the component is a password field.
- I HEAR the required status, instructions, and associated errors, when present.
- I HEAR that entry is protected while the password is hidden, without extra announcements of the password content.
- THEN, when I double-tap or use the appropriate gesture to activate the field and edit its content
- I HEAR or perceive that I can edit the field according to the platform's protected entry behavior, without exposing the password in status messages.
Input validation
- WHEN an entry is rejected by a stated validation rule
- I SEE a message associated with the field explaining how to correct the information
- AND, when I navigate to the field with a screen reader, I HEAR the error indication and associated guidance
- THEN, when I edit again, I SEE the value preserved for correction
Show and hide the password by keyboard
- WHEN I use
Tabto move focus to the "Show password" button while the password is hidden - The focus I SEE is strongly indicated visually
- THEN, when I use
EnterorSpaceto activate the button - I SEE the password in visible text and the button now displays "Hide password"
- AND I SEE the value preserved and focus staying on the button without submitting the form
- THEN, when I use
EnterorSpaceagain - I SEE the password hidden again and the button now displaying "Show password", preserving value and focus without submitting the form
Password visibility with a desktop screen reader
- WHEN I use
Tabto focus the visibility button while the password is hidden - I HEAR that the component is a button named "Show password"
- THEN, when I use
EnterorSpaceto activate the button - I HEAR or perceive that the button's name changed to "Hide password" and focus remains on the button
- THEN, when I activate the button again
- I HEAR or perceive that its name returned to "Show password" and focus remains on the button
- The password value is preserved and the form is not submitted; the password is not included in extra announcements or status messages
Password visibility with a mobile screen reader
- WHEN I swipe to focus the visibility button while the password is hidden
- I HEAR that the component is a button named "Show password"
- THEN, when I double-tap or use the appropriate gesture to activate the button
- I HEAR or perceive that the button's name changed to "Hide password" and focus remains on the button
- THEN, when I activate the button again
- I HEAR or perceive that its name returned to "Show password" and focus remains on the button
- The password value is preserved and the form is not submitted; the password is not included in extra announcements or status messages
Considerations
- Use a persistent label associated with the input. A placeholder is a supplementary hint and does not replace the label.
- Associate instructions and errors with the field, for example using aria-describedby, and set aria-invalid when there is an error.
- Indicate required status and use required when needed. Do not communicate errors solely through color.
- Keep focus visible and ensure adequate contrast and interaction area.
- Allow pasting and password managers. Use autocomplete="current-password" for sign-in and "new-password" for password creation. Hiding characters does not replace data protection.
Text button and optional icons
- This pattern uses "Show password" while content is hidden and "Hide password" while it is visible.
- You can use an open or closed eye icon: an open eye to show content and a closed eye to hide it. The icon represents the available action, matching the button's text.
- Prefer Material Icons: visibility to show and visibility_off to hide. If the icon accompanies text, hide it from assistive technologies using aria-hidden="true".
- If using only an icon, provide the accessible name "Show password" or "Hide password", updated to match the available action.
- Do not block pasting or autofill. Do not log the password or include it in status messages.
References
Field documentation
Design System
- GOV.UK — Password input open_in_new (external link, opens in a new tab) — Specific component with a text button to show and hide the password.
- Carbon — Text input: Password input open_in_new (external link, opens in a new tab) — Password variation with an icon visibility control.
- Bootstrap — Form controls open_in_new (external link, opens in a new tab) — Password field and associated instructions; this example does not include a visibility button.