Slide to Confirm
A slide-to-confirm track. Drag its glass thumb to the end to run one deliberate action; let go early and it springs back.
Latest changeImprovedv1.5.11A success now shows only once the track has drawn in around the thumb, however soon onConfirm settles: the glass takes its colour and the icon turns into the check then, not while the track is still moving. As the check appears the thumb swells and settles, on the same springs a button swells with under the pointer. On a bare track (fill={false}) the landed thumb keeps its clear-glass icon colour until the lens is half frosted over, so the icon never sits dark on dark glass.
- v1.5.11ImprovedA success now shows only once the track has drawn in around the thumb, however soon
onConfirmsettles: the glass takes its colour and the icon turns into the check then, not while the track is still moving. As the check appears the thumb swells and settles, on the same springs a button swells with under the pointer. On a bare track (fill={false}) the landed thumb keeps its clear-glass icon colour until the lens is half frosted over, so the icon never sits dark on dark glass. - v1.5.10ImprovedThe alarm (your own clock, a Snooze button and a bare slide whose thumb mirrors it) is now the preview at the top of the page and the component's tile on the home page. The short "Send" track with its fill and pending action moves to the Examples.
- v1.5.10FixedThe thumb's shadow is no longer cut off at the sides: the glass now has room for all of it, at every size. And after a theme switch the thumb re-reads its colours, so a held thumb no longer shows the old theme's page through it.
- v1.5.9ImprovedThe thumb's rim no longer mirrors the page around the track unless you ask: the new
mirrorprop turns it on, and a colourful neighbour then lights the rim that faces it while the thumb is held, with the icon inside glowing.fill={false}leaves the track bare, with no fill behind the thumb. A new example shows both: an alarm with your own clock, a plain orange Snooze button and a bare slide whose thumb mirrors it. - v1.5.9FixedWhen
onConfirmsettles at once, the icon no longer disappears and comes back before the check. The success now starts as the thumb lands, and a customiconswaps straight to the check: it shrinks, blurs and fades while the check comes in the same way reversed. - v1.5.9ImprovedThe Examples section is back on this page, with the alarm as its one example; the full-width payment and the coloured fills are gone.
- All changes →
Time to wake up
00:00
Use it for
- A routine action a stray tap must not trigger: send money, pay, unlock, start a shift.
- Phone-first surfaces, where a deliberate horizontal gesture replaces a confirm dialog.
Not for
- Easily undone actions: use GlassButton.
- An async action a single press may start: use GlassActionButton.
- Consequences people must read first: use a dialog.
Installation
npx shadcn@latest add https://onemorethink.dev/r/slide-to-confirm.jsonUsage
import { GlassSlideToConfirm } from '@/components/liquid-glass'
<GlassSlideToConfirm
pendingLabel="Sending"
successLabel="Sent"
errorLabel="Not sent, slide to retry"
onConfirm={send} // return the promise
>
Slide to send $240
</GlassSlideToConfirm>The flow
- Idle. The thumb rests at the start as frosted white glass; the instruction is written in the track.
- Drag. The thumb turns to clear glass and bends the fill and the label it passes; its chevron stays in place, in the fill's text colour. It stays round while held, and speed stretches it along its travel. The fill trails a moment behind, joined to the thumb by a bridge that thins as they pull apart, and the track and the fill swell around the thumb like a membrane. Pushed past the end the track stretches like a rubber band; pushed against the start the wall gives a little. The thumb stays round at both.
- Let go early. Below
thresholdthe thumb springs back; the fill's tail follows and is absorbed after it. - Pending. Past the threshold the thumb lands at the end, the track draws in to a ring around it and
pendingLabelappears beside it while a spinner takes the chevron's place, until the promise fromonConfirmsettles. - Success. The white glass takes the fill's colour and the chevron's stroke bends into a check, beside
successLabel; the thumb swells and settles as the check appears. It stays confirmed, unless you setresetAfter: then the track opens first,successLabelleaving with its edge, and the thumb flies home after it, squashing a little as it lands against the start. - Error. If
onConfirmthrows, the track opens again, the thumb returns anderrorLabelreplaces the instruction until the next slide.
Examples
fill={false} leaves the track bare: the thumb pulls no fill behind it and bends the label alone, its icon dark on a light page and white on a dark one; fillClassName then colours only the success. mirror lets the held thumb's rim mirror the page around the track, so a colourful neighbour (the orange button in the preview at the top of this page) lights the rim that faces it, and the icon inside glows. Both are off unless you ask: the thumb mirrors only while it is clear, never at rest.
Colour the fill with fillClassName: its bg-* is the fill, its text-* is the label written on it, and the thumb's icon while the glass is clear. At rest the thumb is always frosted white glass with a dark icon (a flat white disc without WebGL2). The control fills its container, so set the width on a parent or with className.
API reference
| Prop | Type | Default |
|---|---|---|
childrenThe instruction in the track, and the slider's accessible name. | string | — |
onConfirmRequired. Runs once the thumb reaches the end; return a promise to stay pending until it settles. | () => unknown | — |
onConfirmErrorCalled when | (error) => void | — |
pendingLabelWritten beside the spinner while | string | — |
successLabelWritten beside the check after it succeeds. | string | — |
errorLabelReplaces the instruction after a failure, until the next slide. | string | — |
thresholdShare of the track the thumb must pass before letting go confirms. | number | 0.9 |
resetAfterMilliseconds after a success before the track opens again. | number | 0 |
hintNudges the thumb every few seconds until it has been touched. Off with reduced motion. | boolean | true |
iconThe thumb's idle icon. | ReactNode | chevron |
sizeTrack height 40, 48, 56 or 96 px. | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
fillClassNameClasses of the fill: its colour and the colour of the text on it. | string | 'bg-[#3291FF] text-white' |
fill
| boolean | true |
mirrorThe held thumb's rim mirrors the page around the track: a colourful neighbour lights the rim that faces it, and the icon glows. | boolean | false |
disabledDims the control and ignores pointer and keyboard. | boolean | false |
classNameWidth and position of the track. | string | — |
Accessibility
- A real
role="slider"named by its label, witharia-valuenowkept in step with the thumb. - Arrow keys move the thumb in tenths, Page Up and Page Down in quarters, Home returns it and End confirms. Holding Space or Enter glides it to the end; letting go early springs it back.
- A
role="status"region announces the pending, success and error labels. While pending or confirmed the slider isaria-disabled. - Success is never colour alone: the chevron becomes a check and the label is written beside it.
- Vertical page scroll still works over the control on touch. With reduced motion each state shows at once.