Slide to confirm
A measured directional confirmation track with detents, elastic release and async outcomes.
npx @swipeui/cli add slide-to-confirmWhen to use it
- Require a deliberate directional gesture for a clearly explained action.
- Provide a compact confirmation with accessible activation as an alternative.
When not to use it
- Use a drag as the only accessible route to a critical action.
- Infer physical gesture reliability from mocked callbacks.
Installation
Installs with a Pro licence
Everything on this page is public except the source. Founder pre-sale opens around 5 January 2027.
Usage
import { SlideToConfirm } from '@/components/swipeui/ui/slide-to-confirm';
<SlideToConfirm
onConfirm={archiveDraft}
labels={{ idle: 'Slide to archive', success: 'Archived' }}
/>;Examples
Confirm and Disabled. Use Fail next action on Confirm to see the retry state. The app and public preview use the same content and variant names. Demo settings sit outside the component and outcome feedback stays on the action.
Settings
| Setting | Default | Behavior |
|---|---|---|
labels | English labels | Idle/pending/completed/error text, independently replaceable. |
tone | 'primary' | Shared Button tone for track, thumb and feedback. |
hintShimmer | true | Animate the hint with the ambient text shimmer. |
successMorph | true | Expand the successful thumb to fill its track. |
className | undefined | Root styling escape hatch. |
style | undefined | Root native styles. |
accessibilityLabel | current label | Override the spoken action. |
onConfirm | absent | Confirmation work; return a promise to show pending. |
confirmed | undefined | Controlled completion state. |
defaultConfirmed | false | Initial uncontrolled completion. |
onConfirmedChange | undefined | Receives completed confirmation. |
threshold | 0.95 | Fraction of available thumb travel needed for acceptance. |
detents | 4 | Number of haptic progress divisions. |
rubberBand | true | Allow elastic travel beyond the endpoints. |
minPending | 450 | Minimum pending feedback, milliseconds. |
onError | undefined | Reports work failure; the next slide can retry. |
disabled | false | Disable activation and cancel an active drag. |
haptics | true | Independent drag/confirm/result feedback or a global switch. |
motion | app feel | Shared motion feel. |
testID | 'slide-confirm' | Identifier for the gesture recognizer. |
haptics.drag | true | Selection ticks across progress divisions. |
haptics.confirm | true | Impact for accepted confirmation intent. |
haptics.result | true | Success or error outcome notification. |
Composition and behavior
threshold is in (0,1], detents is a positive integer and minPending is milliseconds. A plain view writes both a JS measurement ref and UI shared width; JavaScript confirmation never reads a just-written shared value. Native accessibility exposes Confirm directly. Physical arbitration, haptics and native performance remain 7.9 checks.
A measured thumb accepts at threshold of available travel, with independently configured detents and rubberBand behavior.
Early release returns with release velocity; taps that never activate the pan cannot confirm. RTL mirrors physical travel.
Async work is serial, reports pending/results and allows a fresh slide after failure. hintShimmer and successMorph are independent; shared ambient lifecycle pauses the hint.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
onConfirm | | — | Confirmation work; return a promise to show pending. |
confirmed? | | | Controlled completion state. |
defaultConfirmed? | | | Initial uncontrolled completion. |
onConfirmedChange? | | | Receives completed confirmation. |
threshold? | | | Fraction of available thumb travel needed for acceptance. |
detents? | | | Number of haptic progress divisions. |
rubberBand? | | | Allow elastic travel beyond the endpoints. |
minPending? | | | Minimum pending feedback, milliseconds. |
resetAfter? | | | Successful feedback lifetime in milliseconds; false retains completion. |
onError? | | | Reports work failure; the next slide can retry. |
disabled? | | | Disable activation and cancel an active drag. |
haptics? | | | Independent drag/confirm/result feedback or a global switch. |
motion? | | | Shared motion feel. |
testID? | | | Identifier for the gesture recognizer. |
labels? | | | Idle/pending/completed/error text, independently replaceable. |
tone? | | | Shared Button tone for track, thumb and feedback. |
hintShimmer? | | | Animate the hint with the ambient text shimmer. |
successMorph? | | | Expand the successful thumb to fill its track. |
className? | | | Root styling escape hatch. |
style? | | | Root native styles. |
accessibilityLabel? | | | Override the spoken action. |
Review gates
Founder app and existing pnpm-dev visual acceptance remains open. Native runtime, VoiceOver/TalkBack, haptics, motion, Dynamic Type, RTL and recordings remain pending founder-scheduled 7.9. Source, bundle and unit checks do not establish visual or native acceptance.
| Setting | Default | Behavior |
|---|---|---|
resetAfter | 1800 | Successful feedback lifetime in milliseconds; then return to the normal track. false retains completion. |
Automatic return only resets presentation; it does not undo or repeat the action. Controlled owners receive onConfirmedChange(false) and keep final authority. Timer callbacks use current handlers without restarting the deadline. The handle follows the full measured track directly during a web drag; the release spring and native motion feel remain separate.
Behavior and gestures
- A measured thumb accepts at threshold of available travel, with independently configured detents and rubberBand behavior.
- Early release returns with release velocity; taps that never activate the pan cannot confirm. RTL mirrors physical travel.
- Async work is serial, reports pending/results and allows a fresh slide after failure. hintShimmer and successMorph are independent; shared ambient lifecycle pauses the hint.
- Success remains visible for resetAfter (1800ms by default), then the control morphs back without repeating the action. false retains completion; controlled owners receive a false request. Native thumb geometry is independent of the padded label area.
Accessibility
- Named controls expose unavailable, busy and selected/progress state where applicable. Decorative layers are excluded from interaction.
- Meaningful outcome/availability announcements are distinct from clocks and decorative effects. Native VoiceOver/TalkBack, Dynamic Type, RTL and touch evidence remain pending for 7.9.
Motion
- Uses the
press,morph,numberandambientmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Every decorative duration/spring comes from the shared role helpers. Content clocks remain independent of motion feel.
- Reduce Motion retains readable outcome/progress feedback. Native motion/performance review remains pending.
Performance
- No new package, network service, telemetry or proprietary source.
- Async results and content timers clean up or invalidate after unmount; UI animation values stay on the UI thread.
Notes for AI
- threshold is in (0,1], detents is a positive integer and minPending is milliseconds. A plain view writes both a JS measurement ref and UI shared width; JavaScript confirmation never reads a just-written shared value. Native accessibility exposes Confirm directly. Physical arbitration, haptics and native performance remain 7.9 checks.
- Founder app/web acceptance and all native runtime, accessibility, haptics, motion and recordings remain pending for 7.9.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.