Modus UI

Cipher Reel

Web (React)

A one-time code field of paper slots with serif numerals that drop in and seal on success.

Cipher Reel is a one-time code field. A single hidden input does the typing, pasting and autofill, while serif numerals drop into paper slots; set status to seal the slots on success or shake them on error.

Modus / Cipher Reel

Installation

CLI

npx @modus-ui/cli add cipher-reel

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/cipher-reel.tsx.
  3. Paste the code.

Usage

tsx
import { CipherReel } from "@/components/ui/cipher-reel";

export default function Example() {
  return <CipherReel />;
}

Props

PropTypeDefaultDescription
lengthnumber6Number of slots.
valueany-Controlled code.
defaultValuestring""Initial code when uncontrolled.
onChangeany-Called with the code on every edit.
onCompleteany-Called once every slot is filled.
statusstring"idle""idle", "success" (slots seal) or "error" (field shakes).
maskbooleanfalseShows dots instead of digits.
caretbooleantrueBlinks a caret in the active slot.
disabledbooleanfalseDisables input.
autoFocusbooleanfalseFocuses on mount.
accentColorstring"hsl(var(--primary))"Seal outline on success.
inkColorstring"hsl(var(--foreground))"Active slot outline and caret.
slotColorstring"hsl(var(--muted))"Slot fill.
digitColorstring"hsl(var(--foreground))"Numeral colour.
dangerColorstring"hsl(var(--destructive))"Outline on error.
slotSizenumber48Slot width in pixels.
gapnumber10Space between slots in pixels.
radiusnumber6Slot corner radius in pixels.
bouncenumber0.2Spring bounce as a digit lands.
settlenumber0.3Seal pulse duration in seconds.
risenumber8Height digits drop from, in pixels.
cascadenumber20Delay between slots sealing, in milliseconds.
ariaLabelstring"One-time code"Accessible label.

Comments

  • No comments yet.