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 tiles, two up and two down. A glowing ring glides to the tile that takes the next digit, and each digit stamps down into its tile. While the code is checked, a light runs round the four tiles. A wrong code makes the tiles start to turn, jam after a few pixels and spring back red while the digits drop out. A right one sets the tiles shuffling: a clockwise turn, a diagonal cross where one pair passes over the other, a row swap, a turn back. Then the gaps close, the four become one green square, a check draws across it and a Continue button rises.

Good for
Two-step sign-in, phone and email 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 tiles, so paste, SMS autofill and screen readers work the usual way. Your check runs as soon as the fourth digit is in, and its answer picks the ending. The shuffle is a list of named moves you can reorder or shorten. 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
9 KB gzipped
Dependencies
None
Built with
HTML, CSS, JavaScript
Category
Form
Licence
Unlimited personal and client projects
In the zip
  • riffle.css riffle.jsthe component
  • index.htmla plain example page
  • README.md package.json vite.config.js LICENSE.md

Use it in your project

  1. Copy riffle.css and riffle.js into your project.
  2. Add the markup from index.html (the block between the COMPONENT comments). The grid is four .riffle-tiles, two up and two down.
  3. Start it and connect your own check:
import { init } from './riffle.js';

const riffle = init(document.querySelector('.riffle'), {
  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 grid
  },
  onResend: () => fetch('/api/send-code', { method: 'POST' }),
  onContinue: () => { location.href = '/dashboard'; },
});

onComplete runs as soon as the fourth digit is in. Return false or throw to show an error: the tiles start to turn, jam, spring back red and the digits drop out so the user can type again. Resolve and the tiles shuffle — a clockwise turn, a diagonal cross, a row swap, a turn back — then close the gaps into one green square, a check draws across it and a Continue button appears.

There is one real <input> under the tiles, 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 change the shuffle?

Yes. moves is a list of five named moves (clockwise, anticlockwise, diagonal, columns, rows) in any order and length, and tempo sets the pace.

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 no tile 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