Password inputs

A password field has several jobs before a person submits a form. It hides the value, lets them check what they typed, and explains the relevant requirements. Try the password and inline-validation examples separately: they illustrate different parts of a form, with different rules.

Original catalog components. Changes affect this example only.

Interactive demo. No data is sent.

Let people check their input

Use a made-up value in the password example. The eye control switches between hidden and visible text while keeping the current selection. Try revealing a word, moving the caret, and hiding it again. A reveal action should preserve the work already done rather than clearing the field or jumping to another part of the form.

Give the reveal control a clear accessible name and a visible focus state. Keep it separate from form submission. The example uses a button with type="button", so checking the text does not submit anything. Test it with the keyboard as well as the pointer, especially when several small controls sit beside the input.

Explain requirements where they are needed

The password component opens a requirements panel on focus. Its checklist reflects the entered value, and a separate control can show or hide the panel. Type, remove a character, and reopen it to see whether the information remains consistent. Each line should describe a condition the person can understand and act on.

The shipped example checks a length threshold, letter case, a number, and a symbol. Those checks demonstrate a particular interface; they are not a strength score or a universal password policy. Decide your actual requirements with the authentication system, then align the guidance with the rules that system really accepts.

Keep validation specific to its field

The second example validates a project name, independently of the password field. Check name accepts at least three characters after trimming surrounding whitespace. Try an empty value, a short name, and a longer one. Its message changes next to the input, and editing after a result returns the example to its initial guidance.

This pairing shows two feedback patterns rather than a connected sign-up flow. A project-name check says nothing about a password or an existing account. In your own form, connect each hint to the relevant input and explain the specific correction. Keep client feedback consistent with the server response instead of presenting a local check as final approval.

Match the field to the real form

Choose the input’s autocomplete purpose according to the task. Creating a password and signing in with an existing one are different contexts. The example uses new-password. Keep password-manager behavior in your review, and let people paste into the field. A custom appearance should not make ordinary entry and correction unnecessarily difficult.

The components here do not create an account, authenticate anyone, or store a password. Keep actual credentials out of demonstrations and screenshots. In an application, validate submitted data on the server and handle authentication through its real service. The visual checklist and reveal control are only parts of that larger interaction.

html
<label for="new-password">Password</label>
<input id="new-password" type="password"
  autocomplete="new-password"
  aria-describedby="password-help">
<p id="password-help">Use the requirements for this account.</p>

Review typing, correction, and focus

Test a pasted value, an empty field, a long string, and text entered while an input method is composing. Show and hide the value repeatedly. Open the requirements panel, close it with Escape, then continue typing. Watch whether labels and feedback remain readable on a narrow screen with the panel open.

When you use the SL UI Library package, keep the controller, stylesheet, and adjacent assets together. React and Next.js wrappers mount the same behavior; they do not supply authentication. Ask an AI agent to preserve the input’s semantics and connect the real submit handler explicitly. Finish by checking keyboard focus and reduced motion in the target form.

Reference documentation

Technical documentation behind these examples. You can use the article without opening these links.

More practical guides

Button states: hover, focus, loading, success, and errorDesign clear button states with an interactive example, keyboard focus, loading feedback, and practical HTML, CSS, and JavaScript guidance.Animated buttons with HTML, CSS, and JavaScriptBuild purposeful button animation with CSS transitions, clear interaction states, reversible motion, and a reduced-motion alternative.