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 playgroundDraw 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
npm i @ashutoshswamy/smouiUsage
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.
numberdefault4- label
Accessible name.
stringdefault"Pattern lock"
More inputs components
- AddressAutocompleteType a street and pick from live suggestions. Lookups wait for a pause, show a spinner and drop stale answers. Picking confirms the full address underneath.
- AvatarPickerPick an avatar from a grid. One accent ring glides to your choice, the big preview swaps on a spring, arrow keys move across the grid and Shuffle rolls a random one.
- AvatarUploadDrop or choose a photo, then frame it under a crop circle. The stage shows the whole photo, the circle shows what you keep, and three live previews follow every move. Drag, zoom or use the arrow keys.
- CheckboxBox squashes on press, fills with the accent and draws its tick in.
- ChipA selectable pill. Selecting it tints it and slides a tick in at the front while the pill grows; an optional close button removes it.
- ColorPickerSaturation field and hue strip with jelly thumbs on springs. Edit the hex, pick a swatch, or use arrow keys.