shadcn.io is not affiliated with official shadcn/ui
Change Password Account Block for React
A change-password form that says what it ends: three password fields with a line naming what the new one still needs, boxes for the other sessions, an app password and trusted devices, and a sentence that follows them.
Installation
Overview
Let people change a password and decide what it should end, with this account form for React with Base UI. A compact header holds the title and one sentence. The form is a hairline frame with a plus mark on each corner and three bands. The first holds the current password, the new one and its repeat, each a Password Input with a show button and a line for its problem; under the new password one line counts how many of five requirements are met and names the first one still missing, with no strength meter. The second asks what changing it should end with three Checkbox rows (the other sessions, the app password, the trusted devices) and a sentence that follows them ("You stay signed in here. 3 other sessions end."). The last is the action foot: a status line, the Shine Button that changes the password and an outline Button that clears the form. On a phone the foot stays pinned to the bottom of the screen. It's built from Password Input, Checkbox, Field, Button, Shine Button and Guides, with a CSS entrance only. For the security page of any app, a forced password change or an account recovery step.
FAQ
How do I change the rules and what the boxes cover?
Edit the constants at the top. NEEDS names the five requirements in the order the line reports the first one missing, and metOf says which a password meets; change both together and the count ("3 of 5"), the line and the refusal on submit all follow, since they are worked out from them. SESSIONS, APP_PASSWORDS and DEVICES are what the account holds besides this session: the box titles and the closing sentence are built from them, so they stay true. DEFAULTS says which boxes start ticked.
What happens when I press Change password, and what stays local?
Nothing leaves the page. The button waits less than a second, then clears the form and says in the status line that the password was updated in this demo and nothing was saved; focus moves to that line, since the button disabled itself while it worked. The button is marked aria-disabled rather than disabled while the form is incomplete, so it keeps its place; pressing it (or Enter in a field) shows each problem and moves focus to the first. In your app, post the current and new passwords to your server in submit, then end the sessions, app passwords and trusted devices the boxes name, and show the server's answer in the same line.
How is the current password checked?
It can't be in a demo: any password of 8 or more characters passes, which the first band says beside the fields. A real app checks it on the server before anything changes, which is the point of asking: someone at an unlocked laptop shouldn't be able to take over the account. Keep the field's autocomplete value so a password manager can fill it.
Why a line instead of a strength meter or a checklist?
A meter guesses; the five requirements are rules, so the line says plainly how many are met and the first one still needed, and the field's problem on submit repeats it. Nothing turns green or red: the count and the words carry it, so it reads the same in any theme and to a screen reader. The line has a reserved height, so typing never moves the fields below it.
Is it accessible?
Every field has a visible label and the show button is named; a problem sits in the line under its field, tied to it with aria-describedby, with an icon and words in the text colour. The three boxes are a fieldset with a hidden legend, each named by its title and described by its line. One polite status line is present from the start. The boxes use the Checkbox's checked and onCheckedChange, with each label tied by htmlFor.
How does it look on a phone?
The bands stack with their title over the fields, the three boxes keep their descriptions under them, and the foot sticks to the bottom of the screen while the form scrolls under it, with Change password and Discard side by side. From the medium breakpoint the foot is simply the last band.
Related
- Pro
Change Password Dialog
Account and securityA password manager's account page with its change-password dialog shown open: three password fields, a live checklist of five rules with a strength meter, a match line, and an Update button that stays quiet until every rule passes.
- Pro
Security Review Account
Sessions and devicesA security review in three sections, devices, recent sign-ins and sign-in methods, where each item is answered with Yes, this is mine or Remove, with a progress bar and a Finish button that waits for every answer.
- Pro
Trusted Devices Account
Sessions and devicesAn account's trusted devices as a table of devices against two switches, one to skip the sign-in code and one to skip the password prompt, with a sentence on what each device's choice means and a meter against the limit.
- Pro
Recovery Options Account
Sign-in methodsAn account's recovery options: four numbered ways back in, each with its state in words, a masked value, a quiet test and a one-field form to set it up, and a line that counts how many are ready.
- Pro
Two-Factor Methods Account
Sign-in methodsAn account's two-factor methods as rows with their role, history and a Test that opens a code field in place, Make primary, a guarded Remove, and a Set up that opens a QR code, a key name or a number.
- Pro
Forgot Password Login
Recovery and resetA forgot-password page for a school learning platform that never says whether an account exists, offers the right mail domain when one is a letter off, and resends the link on a 30-second wait.