Skip to content
caliper ui docs

Pro

Combination lock

A combination padlock with number wheels. Roll each wheel by dragging, pressing or with the arrow keys; when the wheels read the code the shackle lifts and swings free.

Pro
pnpm dlx shadcn@latest add @caliper/combination-lock

Vault

The code is 2719. Drag, press or use the arrow keys.

Locked

Not opened yet.

Installs components/ui/combination-lock.tsxDepends on none beyond ReactMotion none in component source

When to use

Use it for

  • Access codes, vaults, escape-room and game screens.
  • A playful way to ask for a short code in a demo or onboarding.

Skip it when

  • Real security; the code is in the page. Use it for delight, not protection.
  • Long codes; past six digits use `OtpInput`.

Decisions

Why it is built this way, so you know what to keep when you change your copy.

Behaviour

Wheels wrap
Each wheel keeps counting in either direction, and the digits above and below fade so the wrap is never seen.
No feedback on wrong digits
It gives no count of correct digits and no tries; the code is the lock.

Usage

Spin buttons
Each wheel is a spin button with a name and a value, takes arrow keys and typed digits, and the state is announced.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/combination-lock

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

Import it from your copy of the source. The example behind the preview comes with the source. It is built from CombinationLock and wheelDigit.

example.tsx
import { CombinationLock, wheelDigit } from "@/components/ui/combination-lock"

The worked example comes with Pro

The 25-line example behind the preview opens here, ready to copy.

  • 626 Pro parts, blocks and page templates, all with source
  • $149 once, with lifetime updates. No renewal
  • A full refund within 14 days if it is not for you
Checking your licence…

API reference

CombinationLock

component

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
code *string—The digits that open it, 3 to 6 of them: "4821".
onUnlock(() => void)—
onLock(() => void)—Called when the lock is closed again.
labelstring"Combination lock"Names the lock, e.g. "Vault".

wheelDigit

component

No props of its own; it accepts the native props of its root element.

Accessibility

It exposes spinbutton, group and status semantics, with aria-label, aria-valuemin, aria-valuemax, aria-valuenow and aria-hidden kept in step with state. Changes that matter are announced through a live region.

KeyBehaviour
↑Moves to the previous item or value.
PageUpMoves by a larger step, or to the previous page.
↓Moves to the next item or value.
PageDownMoves by a larger step, or to the next page.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Changing values examples