The outline button always fails, to show the error
Controls

Passkey Button

Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Passkey Button

A passkey sign-in button with a fingerprint that scans while it waits and draws into a check once verified.

Installation

npx shadcn@latest add ikislay/pixel-ui/passkey-button

How to use

import { PasskeyButton } from "@/components/ui/passkey-button";
import { startAuthentication } from "@simplewebauthn/browser";
export default function Demo() {
return (
<PasskeyButton
onVerify={async () => {
const options = await fetch("/api/passkey/options").then((r) => r.json());
const response = await startAuthentication({ optionsJSON: options });
const res = await fetch("/api/passkey/verify", {
method: "POST",
body: JSON.stringify(response),
});
if (!res.ok) throw new Error("That passkey wasn't recognized.");
}}

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
onVerify
() => unknown

Runs on click. Return a promise to scan until it settles: resolve to verify, throw an Error to show its message. A plain return verifies at once.

status
idlescanningverifiederror

Controls the state yourself. Leave it out and onVerify drives it.

onStatusChange
(status) => void

Called whenever the state changes.

labels
Partial<Record<status, string>>

Overrides the text per state. Defaults are "Sign in with passkey", "Verifying passkey", "Verified" and "Try again".

errorMessage
ReactNode

Shown under the button on error, in place of the thrown error's message.

variant
surfaceprimaryoutline

The button's surface.

size
defaultlg

46px or 54px tall.

fullWidth
boolean

Stretches the button to fill its container.

resetAfter
number

Milliseconds after Verified to return to idle. 0 keeps it verified until clicked.

className
string

Classes applied to the root element.

Controls

Passkey Button

Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Passkey Button
The outline button always fails, to show the error

Passkey Button

A passkey sign-in button with a fingerprint that scans while it waits and draws into a check once verified.

Installation

npx shadcn@latest add ikislay/pixel-ui/passkey-button

How to use

import { PasskeyButton } from "@/components/ui/passkey-button";
import { startAuthentication } from "@simplewebauthn/browser";
export default function Demo() {
return (
<PasskeyButton
onVerify={async () => {
const options = await fetch("/api/passkey/options").then((r) => r.json());
const response = await startAuthentication({ optionsJSON: options });
const res = await fetch("/api/passkey/verify", {
method: "POST",
body: JSON.stringify(response),
});
if (!res.ok) throw new Error("That passkey wasn't recognized.");
}}

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
onVerify
() => unknown

Runs on click. Return a promise to scan until it settles: resolve to verify, throw an Error to show its message. A plain return verifies at once.

status
idlescanningverifiederror

Controls the state yourself. Leave it out and onVerify drives it.

onStatusChange
(status) => void

Called whenever the state changes.

labels
Partial<Record<status, string>>

Overrides the text per state. Defaults are "Sign in with passkey", "Verifying passkey", "Verified" and "Try again".

errorMessage
ReactNode

Shown under the button on error, in place of the thrown error's message.

variant
surfaceprimaryoutline

The button's surface.

size
defaultlg

46px or 54px tall.

fullWidth
boolean

Stretches the button to fill its container.

resetAfter
number

Milliseconds after Verified to return to idle. 0 keeps it verified until clicked.

className
string

Classes applied to the root element.