PatternLock

Connect-the-dots lock. The line follows your finger, dots wake as you reach them, a skipped middle dot is joined for you, and a wrong answer shakes and clears. Keyboard works too. Inputs.

Open playground
Draw a pattern

Hint: draw an L, down the left and along the bottom.

About

PatternLock is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { PatternLock } from "@ashutoshswamy/smoui" and set onComplete, minLength, label.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { PatternLock } from "@ashutoshswamy/smoui";

<PatternLock
  minLength={4}
  onComplete={(dots) => dots.join() === "0,3,6,7,8"} // false rejects
/>

Props 3

onComplete

Dots in connected order, 0 to 8 row by row. Return false to reject.

(pattern: number[]) => boolean | void | Promise<boolean | void>
minLength

Fewest dots that count.

numberdefault 4
label

Accessible name.

stringdefault "Pattern lock"