shadcn.io is not affiliated with official shadcn/ui
WebAuthn Login Block for React
The add-a-passkey page a code host shows after a password sign-in: a three-step setup (where, name, done) with Back, Not now and a Dont ask again box, beside a note on what a passkey is.
Installation
Overview
Ask for a passkey right after the password works, with this WebAuthn login block for React with Base UI. It's the page Forgekeep, a code host, shows just after a password sign-in: the page's rails run the full height of the screen and one band crosses it, split in two. At the start, a read-only Steps (Where, Name, Done) frames three panes in one grid cell. First, "Where should it live?" as native radio rows: this device, a phone or tablet, a security key. Next, "Name it" in a Field, with a default that follows the choice until you type your own. Last, "Passkey saved". The Shine Button is the only colored control and takes its label from the step, with Back, "Not now" and a "Don't ask again" Checkbox under it. At the end, a note says what a passkey is in three facts; on a phone it stacks under the setup. No credential is created, and each result says so. It's built from Steps, Field, Input, Checkbox, Button, Shine Button and Guides, with a CSS entrance only. For code hosts, dashboards and any app that wants passkeys enrolled early.
FAQ
Does this create a real passkey?
No. Create passkey waits 700 ms and shows "Passkey saved", and the result says this demo created no credential and made no request. The page never calls navigator.credentials.create(). In a product, fetch registration options from your server where the code says so, call create() with them, then send the new credential to the server to store its public key and its name.
How do the three steps work?
The indicator is read-only: it shows where you are and ticks off what you have done, but you move with Continue and Back. Each pane shares one grid cell, so the page never changes height, and the pane you leave turns invisible and inert so nothing hidden takes focus. When a step changes, focus moves to its heading and a polite message says which step you are on. "Not now" ends the setup from any step, and "Start over" brings it back.
Why does the name change when I pick another place?
A passkey needs a name you can tell apart later, so the field starts with a sensible one for where it will live: Maya's MacBook, Maya's iPhone, Maya's security key. The default follows your choice until you type your own, and from then on it keeps what you wrote, even if you go back and choose again.
What does Don't ask again do?
Here it only changes the sentence that "Not now" shows: Forgekeep would ask again on your next password sign-in, or would not. In a product, store the choice on the account, not in the browser, and still let people add a passkey later from their security settings, where the user can see and remove every one.
What is the difference between the three places?
This device keeps the passkey on the computer or phone you are on, behind its screen lock. A phone or tablet means you scan a code with that other device and it keeps the passkey. A security key is a separate FIDO2 key you plug in or tap, which also works on devices that can't hold a passkey. The page doesn't detect what your device supports; a real one should, and hide the choices that can't work.
Related
- Pro
Passkey Login
PasswordlessAn online bank's sign-in page and its passkey chooser shown open over a drawn sign-in screen: two passkeys as radio rows, Cancel and Continue, a verifying step and a signed-in result, with the real dialog behind the Use your passkey button.
- Pro
Hardware Key Login
Biometrics and keysA custody service's security-key page: a USB or NFC switch, three sign-in states, one button that waits for the key and then accepts it, and a drawing of a key and a port or a reader.
- Pro
Passwordless Login
PasswordlessA full-height method picker for a podcast app: four hairline radio rows (email link, passkey, text code, authenticator app), a cell that says what happens next for the chosen way, and one button whose label follows the choice.
- Pro
Passkeys Account
Sign-in methodsAn account's passkeys: a ruled list of what each one is, when it was created and last used, a name you edit in place, a guarded Remove, and a dialog from the header that names a new passkey.
- Pro
Biometric Auth Login
Biometrics and keysA health app's sign-in page built around a press-and-hold fingerprint pad: hold it for two seconds to match, let go early and it says so, or press Scan if you cannot hold.
- Pro
Magic Link Login
PasswordlessA full-height passwordless sign-in for a newsletter tool: one email field, then a Check your inbox state with a drawn envelope, a Resend button that really waits 30 seconds, and a way to change the address.