Slide to Unlock

Interactive slider inspired by the classic iPhone “slide to unlock” gesture.

motion-sv
Slide to unlock

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/slide-to-unlock.json

Usage

usage.svelte

Features

  • Smooth drag interaction with spring physics via Motion Svelte
  • Composable compound components (track, handle, text)
  • Customizable handle and colors
  • Built-in shimmering text effect

Examples

Basic

Run a callback when the handle reaches the end of the track.

Slide to unlock

Waiting for the gesture

Reset

Return the handle to its starting position with the reset method.

Slide to unlock

Custom prompt

Change the instruction while the handle is being dragged.

Slide to check in

Custom handle

Provide custom handle content, colors, and drag width.

Slide to launch

Custom handle with a 48px drag width

Confirm action

Replace a one-time confirmation gesture with completion feedback.

Slide to publish

Async action

Show processing and success states after the gesture completes.

Slide to confirm order

Destructive confirmation

Add deliberate friction before a destructive action.

Slide to delete project

Props

SlideToUnlock

Root provider for the slide-to-unlock interaction.

NameTypeDefaultDescription
childrenSnippetrequiredTrack, text, and handle composition rendered inside the root.
handleWidthnumber56Width of the draggable handle in pixels.
onUnlock() => voidundefinedCalled when the handle reaches the end of the track.
refHTMLDivElement | nullnullBindable reference to the root element.
classstringundefinedAdditional classes applied to the root element.

SlideToUnlockTrack

Track that supplies the drag constraint boundary.

NameTypeDefaultDescription
childrenSnippetrequiredText and handle content rendered inside the track.
refHTMLDivElement | nullnullBindable reference to the track element.
classstringundefinedAdditional classes applied to the track.

SlideToUnlockText

Instruction text that fades with drag progress.

NameTypeDefaultDescription
childrenSnippet<[{ isDragging: boolean }]>requiredText renderer receiving the current dragging state.
styleMotionStylePropsundefinedAdditional Motion style values merged with the progress styles.
refHTMLDivElement | nullnullBindable reference to the text element.
classClassValueundefinedAdditional classes applied to the text element.

SlideToUnlockHandle

Draggable handle with a built-in arrow fallback.

NameTypeDefaultDescription
childrenSnippetdefault arrowOptional custom content rendered inside the handle.
styleMotionStylePropsundefinedAdditional Motion style values merged with the drag styles.
refHTMLDivElement | nullnullBindable reference to the handle element.
classClassValueundefinedAdditional classes applied to the handle.