shadcn.io is not affiliated with official shadcn/ui
Password Re-Entry Confirm Dialog Block for React
A hosting dashboard with an alert dialog shown open that asks for the password again before a project is deleted: a lock tile, one field, a Caps Lock note, a count of tries and a destructive confirm.
Installation
Overview
Ask for the password once more before a step that can't be taken back, with this re-entry gate for React with Base UI. It opens from the project settings of Keelhost, a small-site hosting dashboard: the page's header holds an outline Delete project Button, and the page itself, three projects and a Danger zone card, is drawn under a soft scrim inside a hairline frame with a plus mark on each corner. The Alert Dialog puts a lock tile at the start and, beside it, the title, one sentence and a Password Input in a Field. The line under the field is its hint (the demo password), a polite note when Caps Lock is on, or what went wrong: a wrong password says how many tries are left and nudges the field once, and after the third the field locks. Cancel has focus and a click outside doesn't close it. The confirm is a destructive Button, on only once something is typed, so this block has no Shine Button. For preview the dialog is drawn open in place when the page loads; the Delete project button opens the real Alert Dialog. For hosting, billing, account and any product with a step that needs the password again.
FAQ
Why is the dialog already open, and what do I keep?
So you can see it without a click. On load the alert dialog is a copy drawn in place over the page: a native dialog element with the alert dialog role that isn't modal, so nothing is trapped, hidden or focused. The Delete project button opens the real Alert Dialog, modal, with its focus trap, Escape and focus return, and the copy stays closed until a reload. Both show the same ConfirmFields component and share the block's state. In your app keep the Alert Dialog and drop the copy: the "in-place" state, the scrim and the dialog element inside the frame.
What does the dialog check, and how do I wire it for real?
Nothing real. It compares what you type with PASSWORD ("harbour", which the hint gives away), counts three tries, and after the third locks the field until the dialog is opened again. A right password only flips local state: the Danger zone card collapses to a line saying the project was deleted in this demo, and the header's button becomes Undo delete. In your app send the password to your server's re-authentication endpoint in confirm, never compare it in the browser, rate-limit it there, and delete only on a success.
How does it know Caps Lock is on?
From the key events: while you type, each key press and release reports the state of Caps Lock (getModifierState), and the line under the field says "Caps Lock is on" politely. A browser reports it only once a key has been pressed, so the note can't appear before that.
Why is the confirm red, and where is the list of what will be lost?
Because it deletes: a destructive confirm is the destructive Button, not the Shine Button, and the gate stays one field and one sentence. The list of consequences is a different block's job (the account deactivation and deletion dialogs), and a typed project name is the one in the billing downgrade. The button is off until the field has text, and the field takes the rest of the dialog's attention.
Is it accessible from the keyboard?
Yes. The real alert dialog is named by its title and described by its sentence, first focus lands on Cancel, so a stray Enter cancels, and Escape and Cancel return focus to the Delete project button; Enter in the field submits. The trigger is passed to AlertDialogTrigger through render, the dialog is controlled with open and onOpenChange, and first focus is set with initialFocus. The copy shown on load moves no focus. After the project is deleted, focus goes to the header's Undo delete button.
Related
- Pro
Confirm Delete Dialog
Destructive confirmsA planner's project list with its delete confirmation shown open: an alert dialog that lists what goes with the project, asks for its name to be typed exactly, and keeps Delete off until it matches.
- Pro
Delete Account Dialog
Destructive confirmsA notes app's settings page with its account deletion shown open: an alert dialog in three numbered steps, what goes with a real data download, the email typed exactly, then the password and a 14-day grace switch.
- Pro
Downgrade Confirmation Billing
Upgrade and downgradeA downgrade that shows what it costs first: the limits that shrink, the folders now over the smaller plan's storage with a checkbox to archive each and a live meter, the day it takes effect, and an alert dialog that asks for a typed word.
- 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
Deactivate 2FA Dialog
Destructive confirmsA security page with its turn-off confirmation shown open: an alert dialog that lists what goes with two-step verification, asks for the password and a ticked acknowledgement, and keeps its destructive action quiet until both are done.
- Pro
Warning Dialog
Destructive confirmsA hosted database's Migrations page with its caution shown open: an alert dialog with a drawn freeze track and a checkbox that must be ticked before the destructive Run anyway turns on.