import "./components/ui/tidal.css"; import { useEffect, useLayoutEffect, useRef, useState } from "react"; import { ArrowUpRight, Check, Mail, RotateCcw } from "lucide-react"; import { TidalVerificationCode } from "./components/ui/verification-code"; import { TidalButton } from "./components/ui/tidal-button"; import "./components/ui/verification-code.css"; const tidalExampleStyles = ".verification-code-specimen {\n width: 100%;\n max-width: 620px;\n padding: 28px;\n border: 1px solid var(--t-border);\n border-radius: var(--t-radius-card);\n background: var(--t-surface);\n box-shadow:\n 0 24px 40px -28px #00000030,\n 0 2px 4px #00000007;\n}\n.verification-code-specimen > h3 {\n font-size: 29px;\n line-height: 1.08;\n letter-spacing: -1px;\n font-weight: 500;\n margin: 13px 0 26px;\n}\n.verification-code-specimen > h3 > em {\n font-family: \"Instrument Serif\", serif;\n font-size: 1.2em;\n font-weight: 400;\n}\n.code-demo-stage {\n overflow: hidden;\n transition: height 420ms var(--t-ease-out);\n padding: 7px 0;\n}\n.code-demo-content {\n display: flow-root;\n}\n.code-demo-message {\n display: flex;\n align-items: center;\n gap: 18px;\n padding: 22px;\n border: 1px solid var(--t-border);\n border-radius: 12px;\n background: var(--t-subtle);\n position: relative;\n overflow: hidden;\n margin-bottom: 28px;\n}\n.code-demo-message:after {\n content: \"\";\n position: absolute;\n top: 0;\n right: 0;\n width: 16px;\n height: 16px;\n background: linear-gradient(\n 225deg,\n var(--t-surface) 50%,\n var(--t-border) 50%,\n var(--t-subtle)\n );\n pointer-events: none;\n}\n.code-demo-mail {\n display: grid;\n place-items: center;\n width: 48px;\n height: 48px;\n border-radius: 12px;\n background: var(--t-ink);\n color: var(--t-surface);\n transform: rotate(-5deg);\n flex-shrink: 0;\n}\n.code-demo-message .demo-eyebrow {\n font-size: 11px;\n letter-spacing: 1px;\n}\n.code-demo-message strong {\n display: block;\n font-size: 26px;\n letter-spacing: 4px;\n font-weight: 400;\n line-height: 1.1;\n margin: 9px 0;\n font-variant-numeric: tabular-nums;\n}\n.code-demo-message strong > span {\n margin-left: 7px;\n}\n.code-demo-message p {\n font-size: 11px;\n color: var(--t-muted);\n line-height: 1.6;\n margin: 0;\n}\n.code-demo-stamp {\n font-size: 11px;\n letter-spacing: 1px;\n color: var(--t-muted);\n margin-left: auto;\n align-self: flex-end;\n white-space: nowrap;\n}\n.code-demo-checkpoint {\n display: flex;\n align-items: center;\n gap: 12px;\n margin-top: 21px;\n font-size: 11px;\n color: var(--t-muted);\n}\n.code-demo-track {\n width: 52px;\n height: 3px;\n border-radius: 4px;\n background: var(--t-border);\n flex-shrink: 0;\n overflow: hidden;\n}\n.code-demo-track > span {\n height: 100%;\n display: block;\n border-radius: 4px;\n background: var(--t-ink);\n transition: width 420ms var(--t-ease-out);\n}\n.code-demo-actions {\n display: flex;\n gap: 10px;\n margin-top: 22px;\n align-items: center;\n}\n.tidal-scope .code-demo-actions > .tidal-button {\n font-size: 11px;\n flex: 1;\n padding: 0 14px;\n min-width: 0;\n}\n.tidal-scope .code-demo-reset {\n display: grid;\n place-items: center;\n width: 44px;\n height: 44px;\n border: 1px solid var(--t-border);\n border-radius: 10px;\n background: var(--t-subtle);\n color: var(--t-muted);\n flex-shrink: 0;\n transition:\n background 180ms,\n color 180ms,\n transform 320ms var(--t-ease-out);\n}\n.code-demo-reset:hover:not(:disabled) {\n background: var(--t-wash);\n color: var(--t-ink);\n transform: rotate(-12deg);\n}\n.code-demo-reset:disabled {\n cursor: not-allowed;\n opacity: 0.5;\n}\n.code-demo-note {\n font-size: 11px;\n line-height: 1.7;\n color: var(--t-muted);\n margin: 16px 0 0;\n}\n.code-demo-complete {\n text-align: center;\n padding: 27px 23px;\n border: 1px solid var(--t-border);\n border-radius: 12px;\n background: var(--t-subtle);\n animation: code-demo-complete-in 420ms var(--t-ease-out) both;\n}\n.code-demo-success-icon {\n display: grid;\n place-items: center;\n width: 54px;\n height: 54px;\n border-radius: 50%;\n background: var(--t-ink);\n color: var(--t-surface);\n margin: 0 auto 24px;\n animation: code-demo-icon-in 420ms var(--t-ease-spring) both;\n}\n.code-demo-complete > .demo-eyebrow {\n display: block;\n font-size: 11px;\n}\n.code-demo-complete > h4 {\n font-size: 25px;\n line-height: 1.2;\n letter-spacing: -0.8px;\n font-weight: 500;\n margin: 13px 0;\n}\n.code-demo-complete > p {\n font-size: 11px;\n color: var(--t-muted);\n line-height: 1.8;\n max-width: 330px;\n margin: 0 auto 24px;\n}\n.code-demo-complete > .tidal-button {\n font-size: 11px;\n}\n@media (max-width: 480px) {\n .verification-code-specimen {\n padding: 20px;\n }\n .code-demo-message {\n padding: 19px 15px;\n gap: 12px;\n }\n .code-demo-message strong {\n font-size: 22px;\n letter-spacing: 3px;\n }\n .code-demo-stamp {\n display: none;\n }\n .code-demo-actions {\n gap: 7px;\n }\n .tidal-scope .code-demo-actions > .tidal-button {\n font-size: 11px;\n padding: 0 10px;\n }\n}\n@keyframes code-demo-complete-in {\n from {\n opacity: 0;\n transform: translateY(8px);\n }\n to {\n opacity: 1;\n transform: none;\n }\n}\n@keyframes code-demo-icon-in {\n from {\n opacity: 0;\n transform: scale(0.7) rotate(-12deg);\n }\n to {\n opacity: 1;\n transform: none;\n }\n}\n@media (prefers-reduced-motion: reduce) {\n .code-demo-reset:hover:not(:disabled),\n .code-demo-mail {\n transform: none;\n }\n}\n.tidal-scope .code-demo-actions .tidal-button:focus-visible,\n.tidal-scope .code-demo-reset:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: -5px;\n}"; const sample = "548207"; export function VerificationCodeDemo() { const [code, setCode] = useState(""); const [error, setError] = useState(""); const [phase, setPhase] = useState<"editing" | "checking" | "complete">( "editing", ); const [height, setHeight] = useState(); const input = useRef(null); const title = useRef(null); const content = useRef(null); const timer = useRef | undefined>(undefined); const restore = useRef(false); const focusOwner = useRef(null); useEffect(() => () => clearTimeout(timer.current), []); useLayoutEffect(() => { const active = document.activeElement; const canMoveFocus = active === document.body || active === focusOwner.current; if (phase === "complete" && canMoveFocus) { title.current?.focus({ preventScroll: true }); focusOwner.current = null; } else if (phase === "editing" && restore.current) { restore.current = false; if (canMoveFocus) { input.current?.focus({ preventScroll: true }); input.current?.select(); } focusOwner.current = null; } }, [phase]); useLayoutEffect(() => { const node = content.current; if (!node) return; const measure = () => { const css = getComputedStyle(node.parentElement!); setHeight( node.offsetHeight + Number.parseFloat(css.paddingTop) + Number.parseFloat(css.paddingBottom), ); }; measure(); const ro = new ResizeObserver(measure); ro.observe(node); return () => ro.disconnect(); }, []); function reset() { clearTimeout(timer.current); focusOwner.current = document.activeElement instanceof HTMLElement ? document.activeElement : null; setCode(""); setError(""); restore.current = true; setPhase("editing"); if (phase === "editing") { restore.current = false; input.current?.focus({ preventScroll: true }); } } return (
{phase === "complete" ? (
SIX DIGITS · ONE CLEAR NEXT STEP

The sample matched.

This was a local demonstration. No account was accessed and no email was sent.

Try another sample
) : ( <>
ORIGINAL SAMPLE CODE {sample.slice(0, 3)} {sample.slice(3)}

Use these digits to explore the flow.

{ event.preventDefault(); if (code.length !== 6) { setError("Enter all six digits to check the sample."); input.current?.focus({ preventScroll: true }); return; } focusOwner.current = (event.nativeEvent as SubmitEvent).submitter instanceof HTMLElement ? (event.nativeEvent as SubmitEvent).submitter : document.activeElement instanceof HTMLElement ? document.activeElement : null; setError(""); setPhase("checking"); timer.current = setTimeout(() => { if (code === sample) { setCode(""); setPhase("complete"); } else { setError( "Those digits do not match the sample. Try the displayed code.", ); restore.current = true; setPhase("editing"); } }, 700); }} > { setCode(next); setError(""); }} error={error} disabled={phase === "checking"} description="Type the digits, or paste a complete sample code." required />
{phase === "checking" ? "Checking the sample…" : error ? "Review the sample digits" : code.length === 6 ? "Ready for the sample check" : `${code.length} of 6 digits entered`}
{ if (phase === "checking") { reset(); return; } setCode(sample); setError(""); input.current?.focus({ preventScroll: true }); input.current?.setSelectionRange(0, 6); }} > {phase === "checking" ? "Cancel check" : "Fill sample"} Check sample
)}

A local sample, with no delivery, authentication or account access.

); } export default function AgentExample() { return (
); }