{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "login-passkey",
  "type": "registry:component",
  "title": "Login Passkey",
  "description": "A passkey-first sign-in with a large fingerprint that traces its ridges while a scan line sweeps, a Use passkey button with waiting and success states, and a password form that expands smoothly as a fallback.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "auth",
    "login",
    "passkey",
    "webauthn",
    "passwordless",
    "fingerprint",
    "biometric"
  ],
  "docs": "https://hyperblur.dev/effects/login-passkey",
  "files": [
    {
      "path": "registry/hyperblur/login-passkey.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/login-passkey.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface LoginPasskeyLink {\n  label: string;\n  href: string;\n}\n\nexport interface LoginPasskeyValues {\n  email: string;\n  password: string;\n}\n\nexport interface LoginPasskeyProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\" | \"onSubmit\"> {\n  eyebrow?: string;\n  title?: string;\n  subtitle?: string;\n  passkeyLabel?: string;\n  device?: string;\n  defaultExpanded?: boolean;\n  onPasskey?: () => boolean | void | Promise<boolean | void>;\n  onSubmit?: (values: LoginPasskeyValues) => boolean | void | Promise<boolean | void>;\n  forgot?: LoginPasskeyLink;\n  help?: LoginPasskeyLink;\n  accent?: string;\n}\n\nconst css = `\n.hb-qh2 {\n  --hb-qh2-accent: #10b981;\n  position: relative;\n  box-sizing: border-box;\n  width: 100%;\n  overflow: hidden;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  padding: clamp(64px, 9cqw, 112px) 20px;\n}\n.hb-qh2 *, .hb-qh2 *::before, .hb-qh2 *::after { box-sizing: border-box; }\n.hb-qh2::before { content: \"\"; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 50% 60% at 78% 50%, color-mix(in srgb, var(--hb-qh2-accent) 16%, transparent), transparent 70%), linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 100% 48px; mask: linear-gradient(to bottom, transparent, #000 20%, #000 80%, transparent); }\n.hb-qh2-inner { position: relative; max-width: 1120px; margin: 0 auto; display: grid; gap: 40px; align-items: center; }\n.hb-qh2-copy { max-width: 440px; }\n.hb-qh2-eyebrow { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255,255,255,.1); background: #111; color: #a1a1a1; font-size: 12px; }\n.hb-qh2-eyebrow i { width: 6px; height: 6px; border-radius: 50%; background: var(--hb-qh2-accent); box-shadow: 0 0 10px var(--hb-qh2-accent); }\n.hb-qh2-title { margin: 18px 0 12px; font-size: clamp(30px, 4.6cqw, 46px); line-height: 1.05; letter-spacing: -.03em; font-weight: 600; }\n.hb-qh2-sub { margin: 0 0 28px; color: #8f8f8f; font-size: 15px; line-height: 1.6; }\n.hb-qh2-primary { position: relative; width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 52px; border: 0; border-radius: 14px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; color: #04140d; background: var(--hb-qh2-accent); box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 14px 40px -14px var(--hb-qh2-accent); transition: transform .2s, filter .2s; }\n.hb-qh2-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }\n.hb-qh2-primary:disabled { cursor: progress; transform: none; }\n.hb-qh2-primary:focus-visible, .hb-qh2-toggle:focus-visible, .hb-qh2-submit:focus-visible, .hb-qh2-link:focus-visible { outline: 2px solid var(--hb-qh2-accent); outline-offset: 3px; }\n.hb-qh2-device { margin: 12px 0 0; display: flex; align-items: center; gap: 8px; color: #8f8f8f; font-size: 12.5px; }\n.hb-qh2-toggle { margin-top: 22px; width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border: 0; border-top: 1px solid rgba(255,255,255,.08); background: none; color: #ededed; font: inherit; font-size: 14px; cursor: pointer; border-radius: 2px; }\n.hb-qh2-toggle svg { transition: transform .35s cubic-bezier(.2,.7,.2,1); color: #8f8f8f; }\n.hb-qh2-toggle[aria-expanded=\"true\"] svg { transform: rotate(180deg); }\n.hb-qh2-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s cubic-bezier(.2,.7,.2,1), opacity .35s; opacity: 0; }\n.hb-qh2-panel[data-open=\"true\"] { grid-template-rows: 1fr; opacity: 1; }\n.hb-qh2-panel > div { overflow: hidden; }\n.hb-qh2-form { display: grid; gap: 12px; padding: 4px 2px 6px; }\n.hb-qh2-label { display: block; margin-bottom: 6px; font-size: 13px; color: #a1a1a1; }\n.hb-qh2-input { width: 100%; height: 44px; padding: 0 14px; border-radius: 11px; border: 1px solid #262626; background: #111; color: #ededed; font: inherit; font-size: 14px; outline: none; transition: border-color .2s, box-shadow .2s; }\n.hb-qh2-input:focus { border-color: var(--hb-qh2-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-qh2-accent) 22%, transparent); }\n.hb-qh2-input[aria-invalid=\"true\"] { border-color: #f87171; }\n.hb-qh2-err { margin: 6px 0 0; font-size: 12px; color: #fca5a5; }\n.hb-qh2-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }\n.hb-qh2-link { color: #a1a1a1; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255,255,255,.2); border-radius: 3px; }\n.hb-qh2-link:hover { color: #ededed; }\n.hb-qh2-submit { height: 42px; padding: 0 18px; border-radius: 11px; border: 1px solid #333; background: #171717; color: #ededed; font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .2s; }\n.hb-qh2-submit:hover { background: #1f1f1f; }\n.hb-qh2-alert { margin: 14px 0 0; font-size: 13px; color: #fca5a5; }\n.hb-qh2-stage { position: relative; display: grid; place-items: center; aspect-ratio: 1; max-width: 460px; width: 100%; justify-self: center; border-radius: 28px; border: 1px solid rgba(255,255,255,.08); background: radial-gradient(circle at 50% 42%, #141414, #0b0b0b 70%); box-shadow: inset 0 1px 0 rgba(255,255,255,.06); overflow: hidden; }\n.hb-qh2-ring { position: absolute; left: 50%; top: 50%; width: 62%; aspect-ratio: 1; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--hb-qh2-accent) 40%, transparent); transform: translate(-50%, -50%) scale(.6); opacity: 0; animation: hb-qh2-pulse 3.6s cubic-bezier(.2,.7,.2,1) infinite; }\n.hb-qh2-ring:nth-child(2) { animation-delay: 1.2s; }\n.hb-qh2-ring:nth-child(3) { animation-delay: 2.4s; }\n.hb-qh2-print { position: relative; width: 48%; color: color-mix(in srgb, var(--hb-qh2-accent) 85%, white); filter: drop-shadow(0 0 18px color-mix(in srgb, var(--hb-qh2-accent) 45%, transparent)); }\n.hb-qh2-print path { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: 120; stroke-dashoffset: 0; opacity: .35; }\n.hb-qh2-print .hb-qh2-lit { opacity: 1; stroke-dashoffset: 120; animation: hb-qh2-trace 3.2s ease-in-out infinite; }\n.hb-qh2[data-state=\"scanning\"] .hb-qh2-lit { animation-duration: 1.1s; }\n.hb-qh2[data-state=\"success\"] .hb-qh2-lit { animation: none; stroke-dashoffset: 0; }\n.hb-qh2-scan { position: absolute; left: 22%; right: 22%; height: 2px; top: 30%; background: linear-gradient(90deg, transparent, var(--hb-qh2-accent), transparent); box-shadow: 0 0 18px var(--hb-qh2-accent); animation: hb-qh2-sweep 2.4s ease-in-out infinite alternate; }\n.hb-qh2[data-state=\"success\"] .hb-qh2-scan { opacity: 0; }\n.hb-qh2-badge { position: absolute; bottom: 9%; display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px; border-radius: 999px; background: rgba(17,17,17,.9); border: 1px solid rgba(255,255,255,.1); font-size: 12.5px; color: #a1a1a1; }\n.hb-qh2-badge b { color: #ededed; font-weight: 500; }\n.hb-qh2-corner { position: absolute; width: 22px; height: 22px; border: 2px solid color-mix(in srgb, var(--hb-qh2-accent) 60%, transparent); }\n.hb-qh2-c1 { left: 20%; top: 20%; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }\n.hb-qh2-c2 { right: 20%; top: 20%; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }\n.hb-qh2-c3 { left: 20%; bottom: 20%; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }\n.hb-qh2-c4 { right: 20%; bottom: 20%; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }\n.hb-qh2-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(4,20,13,.3); border-top-color: #04140d; animation: hb-qh2-turn .7s linear infinite; }\n@container (min-width: 760px) {\n  .hb-qh2-inner { grid-template-columns: 1fr 1fr; gap: 64px; }\n}\n@keyframes hb-qh2-pulse { 0% { opacity: .7; transform: translate(-50%, -50%) scale(.6); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } }\n@keyframes hb-qh2-trace { 0% { stroke-dashoffset: 120; } 50% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -120; } }\n@keyframes hb-qh2-sweep { from { top: 26%; } to { top: 72%; } }\n@keyframes hb-qh2-turn { to { transform: rotate(360deg); } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-qh2 *, .hb-qh2 *::before, .hb-qh2 *::after { animation: none !important; transition: none !important; }\n  .hb-qh2-print .hb-qh2-lit { stroke-dashoffset: 0; }\n}\n`;\n\nconst ridges = [\n  \"M32 10c-10 0-18 6-21 15\",\n  \"M53 25c-3-9-11-15-21-15\",\n  \"M18 30c2-8 8-13 14-13s12 5 14 13\",\n  \"M14 40c0-3 0-6 1-9\",\n  \"M49 31c1 4 1 9 1 13\",\n  \"M22 50c-1-5-2-10-1-16 1-6 5-10 11-10s10 4 11 10c1 4 1 9 0 13\",\n  \"M27 54c-2-6-3-12-2-18 1-4 3-6 7-6s6 2 7 6c1 5 0 11-2 16\",\n  \"M32 36c0 8 0 14-3 22\",\n  \"M38 42c0 6-1 12-4 17\",\n  \"M44 50c-1 4-2 8-4 11\",\n];\n\nfunction wait(result: unknown, ms: number) {\n  return result instanceof Promise ? result : new Promise<unknown>((resolve) => setTimeout(() => resolve(result), ms));\n}\n\nexport function LoginPasskey({\n  eyebrow = \"Passwordless by default\",\n  title = \"Sign in with a touch\",\n  subtitle = \"Your passkey lives on this device and unlocks Ledgerly with Touch ID, Face ID or your screen lock. Nothing to remember, nothing to phish.\",\n  passkeyLabel = \"Use passkey\",\n  device = \"MacBook Pro · last used 2 days ago\",\n  defaultExpanded = false,\n  onPasskey,\n  onSubmit,\n  forgot = { label: \"Forgot password?\", href: \"#forgot\" },\n  help = { label: \"What is a passkey?\", href: \"#passkeys\" },\n  accent = \"#10b981\",\n  className = \"\",\n  style,\n  ...rest\n}: LoginPasskeyProps) {\n  const uid = React.useId();\n  const [open, setOpen] = React.useState(defaultExpanded);\n  const [state, setState] = React.useState<\"idle\" | \"scanning\" | \"success\" | \"error\">(\"idle\");\n  const [email, setEmail] = React.useState(\"\");\n  const [password, setPassword] = React.useState(\"\");\n  const [errors, setErrors] = React.useState<{ email?: string; password?: string }>({});\n  const [formBusy, setFormBusy] = React.useState(false);\n  const [formError, setFormError] = React.useState(\"\");\n\n  async function startPasskey() {\n    if (state === \"scanning\" || state === \"success\") return;\n    setState(\"scanning\");\n    try {\n      const result = await wait(onPasskey ? onPasskey() : true, 1600);\n      setState(result === false ? \"error\" : \"success\");\n    } catch {\n      setState(\"error\");\n    }\n  }\n\n  async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (formBusy) return;\n    const next: { email?: string; password?: string } = {};\n    if (!/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email.trim())) next.email = \"Enter a valid email address.\";\n    if (password.length < 8) next.password = \"Use at least 8 characters.\";\n    setErrors(next);\n    setFormError(\"\");\n    if (next.email || next.password) return;\n    setFormBusy(true);\n    try {\n      const result = await wait(onSubmit ? onSubmit({ email: email.trim(), password }) : true, 900);\n      if (result === false) setFormError(\"Incorrect email or password.\");\n      else setState(\"success\");\n    } catch {\n      setFormError(\"Something went wrong. Try again.\");\n    }\n    setFormBusy(false);\n  }\n\n  const statusText = state === \"scanning\" ? \"Waiting for your device\" : state === \"success\" ? \"Verified\" : state === \"error\" ? \"Not verified\" : \"Ready\";\n\n  return (\n    <section className={`hb-qh2 ${className}`} data-state={state} style={{ \"--hb-qh2-accent\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-login-passkey\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qh2-inner\">\n        <div className=\"hb-qh2-copy\">\n          <span className=\"hb-qh2-eyebrow\"><i aria-hidden=\"true\" />{eyebrow}</span>\n          <h2 className=\"hb-qh2-title\">{state === \"success\" ? \"You're in.\" : title}</h2>\n          <p className=\"hb-qh2-sub\">{state === \"success\" ? \"Verified with your passkey. Loading your books for this quarter.\" : subtitle}</p>\n          <button type=\"button\" className=\"hb-qh2-primary\" onClick={startPasskey} disabled={state === \"scanning\" || state === \"success\"} aria-busy={state === \"scanning\"}>\n            {state === \"scanning\" ? <span className=\"hb-qh2-spin\" aria-hidden=\"true\" /> : (\n              <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n                <circle cx=\"8\" cy=\"8\" r=\"4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" />\n                <path d=\"M11 11l9 9M17 17l2-2M15 15l2-2\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" />\n              </svg>\n            )}\n            {state === \"scanning\" ? \"Confirm on your device\" : state === \"success\" ? \"Signed in\" : passkeyLabel}\n          </button>\n          <p className=\"hb-qh2-device\" role=\"status\">\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><rect x=\"2\" y=\"3\" width=\"12\" height=\"8\" rx=\"1.5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.3\" /><path d=\"M1 13h14\" stroke=\"currentColor\" strokeWidth=\"1.3\" strokeLinecap=\"round\" /></svg>\n            {state === \"error\" ? \"Passkey was cancelled. Try again or use your password.\" : device}\n          </p>\n          <button type=\"button\" className=\"hb-qh2-toggle\" aria-expanded={open} aria-controls={`${uid}-panel`} onClick={() => setOpen((o) => !o)}>\n            Sign in with password instead\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\"><path d=\"m4 6 4 4 4-4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" /></svg>\n          </button>\n          <div className=\"hb-qh2-panel\" id={`${uid}-panel`} data-open={open} aria-hidden={!open}>\n            <div>\n              <form className=\"hb-qh2-form\" noValidate onSubmit={handleSubmit}>\n                <div>\n                  <label className=\"hb-qh2-label\" htmlFor={`${uid}-email`}>Work email</label>\n                  <input id={`${uid}-email`} className=\"hb-qh2-input\" type=\"email\" autoComplete=\"email webauthn\" placeholder=\"dana@ledgerly.io\" tabIndex={open ? 0 : -1} value={email} aria-invalid={errors.email ? true : undefined} aria-describedby={errors.email ? `${uid}-ee` : undefined} onChange={(e) => setEmail(e.target.value)} />\n                  {errors.email && <p className=\"hb-qh2-err\" id={`${uid}-ee`}>{errors.email}</p>}\n                </div>\n                <div>\n                  <label className=\"hb-qh2-label\" htmlFor={`${uid}-pw`}>Password</label>\n                  <input id={`${uid}-pw`} className=\"hb-qh2-input\" type=\"password\" autoComplete=\"current-password\" tabIndex={open ? 0 : -1} value={password} aria-invalid={errors.password ? true : undefined} aria-describedby={errors.password ? `${uid}-pe` : undefined} onChange={(e) => setPassword(e.target.value)} />\n                  {errors.password && <p className=\"hb-qh2-err\" id={`${uid}-pe`}>{errors.password}</p>}\n                </div>\n                <div className=\"hb-qh2-row\">\n                  <a className=\"hb-qh2-link\" href={forgot.href} tabIndex={open ? 0 : -1}>{forgot.label}</a>\n                  <button type=\"submit\" className=\"hb-qh2-submit\" tabIndex={open ? 0 : -1} disabled={formBusy} aria-busy={formBusy}>{formBusy ? \"Checking\" : \"Continue\"}</button>\n                </div>\n                {formError && <p className=\"hb-qh2-alert\" role=\"alert\">{formError}</p>}\n              </form>\n            </div>\n          </div>\n          <a className=\"hb-qh2-link\" href={help.href}>{help.label}</a>\n        </div>\n        <div className=\"hb-qh2-stage\" aria-hidden=\"true\">\n          <span className=\"hb-qh2-ring\" />\n          <span className=\"hb-qh2-ring\" />\n          <span className=\"hb-qh2-ring\" />\n          <span className=\"hb-qh2-corner hb-qh2-c1\" />\n          <span className=\"hb-qh2-corner hb-qh2-c2\" />\n          <span className=\"hb-qh2-corner hb-qh2-c3\" />\n          <span className=\"hb-qh2-corner hb-qh2-c4\" />\n          <svg className=\"hb-qh2-print\" viewBox=\"0 0 64 64\">\n            {ridges.map((d, i) => <path key={`b${i}`} d={d} />)}\n            {ridges.map((d, i) => <path key={`l${i}`} d={d} className=\"hb-qh2-lit\" style={{ animationDelay: `${(i * 0.12).toFixed(2)}s` }} />)}\n          </svg>\n          <span className=\"hb-qh2-scan\" />\n          <span className=\"hb-qh2-badge\">Status <b>{statusText}</b></span>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}