0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…
Slide-to-confirm interaction with drag handle, spring-back animation, keyboard support, and progressive enhancement.
Overview
The <slide-accept> component creates a slide-to-confirm interaction — a draggable handle that users slide across a track to confirm an action (like iOS “slide to power off”). If released early, the handle springs back. Once the threshold is reached, the component activates and fires a slide-accept:accept event.
Basic slide-to-confirm
1234
<!-- The text content is the no-JS fallback and the default label --><slide-acceptactivated-label="Confirmed!"> Slide to confirm</slide-accept>
Track label and the handle’s accessible name. Without it, the element’s own text content (the no-JS fallback) is used, so a translated fallback stays translated. Changes after upgrade are applied.
activated-label
string
"Confirmed!"
Label shown after activation; announced through a polite live region and used as the handle’s aria-valuetext.
data-label-hint
string
"Press Enter to confirm"
Screen-reader hint linked to the handle with aria-describedby. Translate it with the label.
data-label-required
string
"{label} to continue."
Validation message when the control is required and not confirmed. {label} is replaced by the label.
attention
string
—
Attention animation: "shimmer" or "pulse".
threshold
number
90
Drag activation threshold as a percentage (0–100).
name
string
—
Form field name. The element is form-associated and submits value only once confirmed.
value
string
"on"
Value submitted once confirmed.
required
boolean
—
The form will not submit until the slider is confirmed (valueMissing).
disabled
boolean
—
Blocks dragging, tapping and keys. A disabled <fieldset> does the same.
Attention Animations
Shimmer
A sweeping shimmer effect draws attention to the track, encouraging interaction (see the demo above).
Shimmer attention
123456
<slide-acceptlabel="Slide to delete"activated-label="Deleted!"attention="shimmer"> Slide to delete</slide-accept>
Pulse
A pulsing glow on the handle draws attention to the draggable element (see the demo above). Both attention animations are off under reduced motion.
Pulse attention
123456
<slide-acceptlabel="Slide to send"activated-label="Sent!"attention="pulse"> Slide to send</slide-accept>
Custom Threshold
By default, the handle must be dragged to 90% of the track to activate. Set threshold to a lower value to make dragging easier. The threshold applies to dragging and arrow keys only: a tap, Enter, Space or End confirms at once.
Custom threshold
123456
<!-- Activate at 60% instead of default 90% --><slide-acceptlabel="Slide halfway"threshold="60"> Slide halfway</slide-accept>
Keyboard and pointer
Dragging is never the only way to confirm (WCAG 2.5.7). A tap or click on the handle — pressing and releasing without dragging — confirms at once.
Input
Action
Enter, Space, End
Confirm immediately
Tap or click the handle
Confirm immediately
ArrowRight / ArrowUp
Move the handle 5% towards the end (ArrowLeft in right-to-left pages); confirms at the threshold
Shift + arrow
Move the handle 20%
ArrowLeft / ArrowDown
Move the handle back 5% (ArrowRight in right-to-left pages)
Home
Move the handle back to the start
Events
Event
Description
slide-accept:accept
Fired once when confirmed: dragged past the threshold, tapped, or Enter / Space / End.
slide-accept:reset
Fired after reset() is called (also when the owning form is reset after confirming).
The handle is a <div role="slider"> named by label, with aria-valuenow and an aria-valuetext of the percentage (the activated label once confirmed). A visually hidden hint (data-label-hint, default “Press Enter to confirm”) is linked with aria-describedby.
Single-pointer alternative
WCAG 2.5.7 requires a non-dragging way to complete a drag action. A tap or click on the handle confirms, as do Enter, Space and End. If you need protection from an accidental single tap, put the confirm step behind a dialog instead — a slider alone is not a safety mechanism for assistive-technology users.
Focus and announcement
After confirming, the handle keeps focus and stays in the tab order with aria-disabled="true". The track label is a polite role="status" region, so the change to activated-label is announced.
Right-to-left
In right-to-left pages the handle starts at the right and travels left; dragging, arrow keys and the chevron icon all follow the direction.
Forced colors
In Windows High Contrast the handle gets a ButtonText border, the fill uses Highlight, and the confirmed track switches to a double border, so state is not conveyed by colour alone.
Reduced Motion
Spring-back animation and attention effects are disabled when prefers-reduced-motion: reduce is active.
Forms
<slide-accept> is form-associated. Give it a name to submit value (default "on") once confirmed, and required to block submission until then. Resetting the form resets the slider.
Gate a form submit
1234
<form><slide-acceptname="consent"required>Slide to accept the terms</slide-accept><buttontype="submit">Continue</button></form>
Styling
The track, handle, and label are all styleable with CSS. The handle is a .slide-handle element with role="slider" (deliberately not a <button>, so theme button styles do not leak in), inside a .slide-track; the text is .slide-label.
Custom styling
123456789
/* Custom handle color */slide-accept .slide-handle {background: oklch(55%0.230);}/* Custom activated state */slide-accept[data-activated].slide-handle {background: oklch(50%0.15145);}
Progressive Enhancement
Without JavaScript, the element renders its text content as a readable pill-shaped element. The :not(:defined) selector provides the fallback. Once JS registers the component, the track and drag handle take over.
No-JS fallback
1234567
/* Without JS: renders as pill-shaped inline element */slide-accept:not(:defined) {display: inline-flex;padding: var(--size-xs) var(--size-m);border-radius: var(--radius-pill);background: var(--color-surface-raised);}