Staaarter

Recovery Codes

Full-height two-factor backup screen showing a grid of single-use recovery codes with real copy-to-clipboard and download-as-file actions, a safety warning, and a confirmation checkbox that gates the continue button.

By Staaarter Team
Auth
Docs
Live preview

Docs

Installation

A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button dependencies and any missing npm packages, and installs them straight into your project.

npx shadcn add https://staaarter.com/r/recovery-codes.json

Prefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/auth/auth22.tsx instead.

Usage

The file also exports auth22Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.

import { Auth22, auth22Demo } from "@/components/blocks/auth/auth22";

export default function Page() {
  return <Auth22 {...auth22Demo} />;
}

Props

PropTypeDefaultDescription
headingstringnoneScreen heading.
descriptionstringnoneShort explanation shown under the heading.
codesstring[]noneRecovery codes to render in the grid, in display order.
warningTextstringnoneText shown inside the safety warning callout.
confirmLabelstringnoneLabel next to the confirmation checkbox.
continueLabelstringnoneLabel for the continue button.
classNamestringnoneExtra classes for the outer section element.

Behavior notes

  • Copy all uses navigator.clipboard.writeText wrapped in try/catch and shows a visible 'Copied!' label for 2 seconds via local state; if the clipboard API is denied or unavailable it silently no-ops instead of throwing.
  • Download builds a real Blob of the codes joined by newlines and triggers a synthetic <a download> click to save recovery-codes.txt; no network request is made.
  • The confirmation checkbox is a hand-written native input (no shared Checkbox component exists in this kit) paired with a real <Label htmlFor>, and its checked state disables the Continue button until checked.
  • The recovery codes themselves are static demo values, not real backup codes tied to any account.