Slide to Unlock
The iPhone OS 1 lock-screen slider: a 280x47 inset glass well, a glossy 82x43 arrow knob that follows the pointer 1:1 and springs back, and a shimmering label. A keyboard-operable role="slider" that unlocks on Enter, Space or End.
Installation
Requires the theme. Register the @skeuomorph namespace and add @skeuomorph/skeuomorph first, as shown in the installation guide. The CLI also pulls it in as a dependency.
Without the namespace, install straight from the URL:
Usage
import { SlideToUnlock } from "@/components/ui/slide-to-unlock"<SlideToUnlock onUnlock={() => router.push("/home")} />The track is a translucent black well, so it belongs on a dark surface such as linen (material-linen) or an iOS glass tray.
Behaviour
- Drag. The knob follows the pointer 1:1 using pointer capture. Release it past 90% of the track to unlock. Anything less springs back over 280ms with
ease-out-quart. - Tap. Tapping the knob without dragging runs it across and unlocks. This is the single-pointer alternative to the drag that WCAG 2.5.1 asks for.
- Keyboard. The knob is a focusable
role="slider"(aria-valuemin0,aria-valuemax100,aria-valuetext"Locked" or "Unlocked"). Enter, Space or End unlocks. The arrow keys move it in 10% steps and Home sends it back. A half-slid knob springs home when focus leaves. - Shimmer. The label's bright band sweeps for 2.0s and rests for 0.6s. It pauses offscreen, in background tabs and while dragging. Under
prefers-reduced-motionthe shimmer and the spring are off, and the label is static. - RTL. Under
dir="rtl"the travel, the arrow and the shimmer direction flip.
Locking again
Once unlocked, the slider stays unlocked. To lock it again, render it with a new key:
const [generation, setGeneration] = React.useState(0)
<SlideToUnlock key={generation} onUnlock={openHome} />
<Button variant="secondary" onClick={() => setGeneration((n) => n + 1)}>
Lock
</Button>API
Every other div prop is passed to the track. Parts carry data-slot="slide-to-unlock", "unlock-label" and "unlock-knob", and the track has data-state="locked" | "unlocked".