Bundles save up to 25%. See every bundle

Code Boss
Dark

Full screen

What it does

A complete "enter the code we sent you" card with four pieces in a row, each with a dovetail tab on one side and the matching socket on the other. A glowing outline in the shape of the piece glides to the one that takes the next digit, and each digit stamps down into its piece. While the code is checked, a light runs along the row, piece by piece and gap by gap. A wrong code makes the pieces lunge to join, but every other one sits a little high or low, so the tabs knock against the edges and the row springs back apart in red while the digits drop out. A right one lifts every other piece, slides the row shut underneath and presses each lifted piece down into its sockets with a small flash at each joint. The row becomes one green bar, the joints fade to a faint inlay, a check draws across it and a Continue button rises.

Good for
Two-step sign-in, email and phone confirmation, PIN-style confirmations, any screen that asks for a short one-time code and deserves a moment at the end.
How it works
One real input sits invisibly over the pieces, so paste, SMS autofill and screen readers work the usual way. Each piece is an SVG outline drawn from its measured size, so the tabs fit at any size, from desktop down to a 320px phone. Your check runs as soon as the last digit is in, and its answer picks the ending. The code length follows the number of pieces in the markup. A resend button counts down before it can be pressed.
How to use
Copy two files, paste the markup, pass your own onComplete(code).

Specs

Price
$12, one payment
Version
1.0.0
Code size
11 KB gzipped
Dependencies
None
Built with
HTML, CSS, JavaScript
Category
Form
Licence
Unlimited personal and client projects
In the zip
  • dovetail.css dovetail.jsthe component
  • index.htmla plain example page
  • README.md package.json vite.config.js LICENSE.md

Use it in your project

  1. Copy dovetail.css and dovetail.js into your project.
  2. Add the markup from index.html (the block between the COMPONENT comments). The row has one .dovetail-piece per digit; four in the example. Add or remove pieces to change the code length.
  3. Start it and connect your own check:
import { init } from './dovetail.js';

const dovetail = init(document.querySelector('.dovetail'), {
  onComplete: async (code) => {
    const res = await fetch('/api/verify', { method: 'POST', body: JSON.stringify({ code }) });
    if (!res.ok) throw new Error('That code has expired. Send a new one.'); // shown under the row
  },
  onResend: () => fetch('/api/send-code', { method: 'POST' }),
  onContinue: () => { location.href = '/dashboard'; },
});

onComplete runs as soon as the last digit is in. Return false or throw to show an error: the pieces lunge to join, but every other one sits a little high or low, so the tabs knock against the edges and everything springs back apart in red while the digits drop out. Resolve and every other piece lifts, the row slides shut underneath, and each lifted piece is pressed down into its sockets with a flash at each joint. The row becomes one green bar, the joints fade to a faint inlay, a check draws across it and a Continue button appears.

Each piece is an SVG outline drawn from its measured size, so a tab always fits the next socket exactly at any size. There is one real <input> under the pieces, so the things that normally work with a code field still do: paste, SMS and email autofill (autocomplete="one-time-code"), the numeric keyboard on phones, and screen readers.

Questions

What exactly do I get?

The full source, an example page and a README. No account, no framework.

Can I use it in client projects?

Yes, in unlimited projects. You can't resell or share the source itself.

Does it check the code?

It calls your function with the code and shows the answer. Checking belongs on your server; the demo only compares against a fixed code.

Can I use six digits?

Yes. Add two more .dovetail-piece elements and narrow --dovetail-w and --dovetail-gap so the row fits your card.

Does autofill from SMS work?

Yes. It's a normal input with autocomplete="one-time-code", so iOS and Android offer the code from the message, and the digits stamp in one after another.

Is it accessible?

One labelled field, numeric keyboard on phones, live status messages, aria-invalid on errors, and focus moves to Continue once verified. With reduced motion nothing travels.

Light and dark?

Both are designed, and every colour is a CSS variable.

What if it doesn't work for me?

If it doesn't work like the demo, you get a refund within 14 days.

Still have a question? Email us. The person who made it answers.

Your cart

Your cart is empty. Browse components

Full screen