Live demo
Demo source
Use a password field for any secret value, such as a password, a PIN or an access key. The input hides the characters, and people can show them to check what they typed.
Anatomy
A password field with four callouts: 1 marks the label Field label, 2 the input showing the placeholder Input example, 3 the description below it, and 4 the eye button at the right end of the input.
- Label (optional) says which secret to enter.
- Input hides the value. An icon can sit before it in the
leading-inputslot. - Description (optional) states the requirements.
- Show password button switches between hidden and visible text.
hidePasswordIconremoves it, andshowPasswordsets the visibility from code.
States
Hover and focus styles are built in. required marks the label with an
asterisk. A disabled field cannot be used, and a read-only value can still be
shown and copied. Set error with an errorDescription that says how to meet
the requirements, or success once they are met.
Validation feedback
The error state combines a red outline, warning icon and explanatory text; success uses a green outline and check icon. Your application decides when the requirements are satisfied. Keep the requirements visible in the description while the user edits.
Width
The field fills its container up to 480 px; use fluid to fill a wider
container.
Themes
The design includes Spark and Ocean appearances. Use the page's theme and mode controls to compare the live examples; retain the same labels, states and validation messages in each theme.
Guidelines
- Name the secret in the label, such as "New password" or "Current password".
- State requirements before people type, not only in error messages.
- Put instructions in the description, not the placeholder.
- Allow copying and pasting, and set
autocompletetonew-passwordorcurrent-passwordso password managers can help. - Validate as people enter the password and give timely feedback about which requirements remain unmet.
- Never show or log the value elsewhere on the page.