Most one-time-code screens get the same thing wrong: they build six separate <input>s, one per digit. It looks right, and then it breaks the moment a real person uses it. Paste "482913" from an email and only the first box fills. The phone's "From Messages: 482913" suggestion does nothing. A screen reader announces six unlabelled fields. Backspace jumps around.

I built a passwordless login for DeliverWebsite UI where the code boxes are postage stamps, and the part I'm happiest with isn't the stamps. It's that there's one real input behind all six of them. Here's how it works, with the real code.

The whole component is free: Magic link login page with a 6-digit code (React, Tailwind CSS, Motion).

The flow

The login is told as a letter, on airmail blue:

  1. You type your email straight onto a white envelope.
  2. Press send: a postmark with today's date lands across the red stamp, and the letter flies off the screen.
  3. A strip of six postage stamps appears. You enter the code from your inbox, one digit per stamp.
  4. Right code: you're in. Wrong code: the strip shakes, the digits clear, and you try again.

No password field anywhere.

One input, six stamps

The six stamps are just drawings. They're aria-hidden, and each one shows a digit from the value. On top of the whole strip sits a single, invisible, full-size input:

export const CODE_LENGTH = 6; <div className="relative w-fit"> <label htmlFor={id} className="sr-only">{label}</label> {/* six stamps: decoration only */} <div aria-hidden className="flex gap-2.5"> {Array.from({ length: CODE_LENGTH }, (_, index) => ( <div key={index} className="grid h-16 w-12 place-items-center bg-white"> <span className="font-mono text-2xl font-bold">{value[index]}</span> </div> ))} </div> {/* the one real input, laid over the whole strip */} <input id={id} value={value} onChange={(event) => onChange(event.target.value.replace(/\D/g, "").slice(0, CODE_LENGTH))} inputMode="numeric" autoComplete="one-time-code" maxLength={CODE_LENGTH} className="absolute inset-0 size-full text-transparent caret-transparent outline-none" /> </div> 

Because it's one ordinary input:

  • Pasting works. Paste the whole code and all six stamps fill at once.
  • The phone's code suggestion works. autoComplete="one-time-code" lets iOS and Android offer the code from the SMS or email above the keyboard.
  • The number pad opens on phones. inputMode="numeric".
  • Screen readers hear one labelled field ("Six-digit code"), not six unnamed ones.
  • Backspace, arrow keys and select-all behave normally, because it's a real text field.
  • Anything that isn't a digit is dropped, so pasting "482 913" or "Code: 482913" still works.

The text and caret are transparent so you only see the stamps, and the next empty stamp gets an outline so you know where you are:

className={cn( "relative grid h-16 w-12 place-items-center bg-white", index === value.length && !isDisabled && "outline-2 outline-offset-2 outline-white", )} 

Checking the code

When the sixth digit lands, the component checks it straight away. No "Verify" button to hunt for:

const enterCode = async (next: string) => { setDigits(next); setIsWrong(false); if (next.length < CODE_LENGTH) return; setStep("checking"); const isRight = onVerify ? await onVerify(next) : true; if (isRight) return setStep("in"); setIsWrong(true); await pause(600); setDigits(""); setStep("code"); }; 

You pass your own onSend(email) and onVerify(code), so it works with whatever sends your magic links (Supabase, Clerk, Auth.js, your own API).

A wrong code shakes the strip and turns the digits red, and the error is a real role="alert" message, so it's announced too:

<motion.div animate={isWrong ? { x: [0, -8, 8, -5, 5, 0] } : { x: 0 }} transition={{ duration: 0.4 }}> {/* stamps + input */} </motion.div> {isWrong && <p role="alert" className="text-sm text-red-300">{code.error}</p>} 

The letter that flies away

The envelope is a form. When it's sent, it leaves with a small exit animation, up and to the right, with a slight tilt, like a letter going into a postbox:

<motion.form onSubmit={post} exit={isReduced ? { opacity: 0 } : { x: "115%", y: "-25%", rotate: 9, opacity: 0 }} transition={{ duration: 0.55, ease: [0.22, 1, 0.36, 1] }} > 

With prefers-reduced-motion on, it just fades, and every wait in the flow is skipped. The heading above the form is an aria-live region, so screen-reader users hear "Check your inbox" when the step changes.

Why bother with the stamps at all

A login page is the one page every user sees, and usually the most forgettable. The letter metaphor does a job: it explains what's happening (we're sending you something, go check your inbox) without a paragraph of instructions, and it makes waiting for an email feel like part of the experience instead of a dead end.

But the metaphor only works because the boring parts are solid: one real input, paste, autofill, a labelled field and an announced error. If you build your own code input, build those first and draw whatever you like on top.

Grab the full component free at DeliverWebsite UI.