Slide to confirm
Slide-to-confirm track for deliberate actions: the handle must reach the end, keyboard users hold Enter, and it re-arms after a delay.
Playground
Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.
<HfSwipe
label="Slide to deploy"
doneLabel="Deployed"
hint="Drag the handle all the way, or hold Enter"
doneHint="Deploy started · production"
reset={2800}
/>Installation
pnpm dlx shadcn@latest add @lumesec/hf-swipeFirst timeRegister the @lumesec registry once, or install by URL+
Adds @lumesec to your components.json:
pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.jsonOr skip the setup and install by URL:
npx shadcn@latest add https://elements.lumesec.ai/r/hf-swipe.jsonUsage
import { HfSwipe } from "@/components/lumesec/hf-swipe";
export function Example() {
return (
<HfSwipe label="Slide to deploy" doneLabel="Deployed" />
);
}Behaviour
For actions that shouldn’t happen by accident. A sheen runs across the label, the track fills behind the handle, and reaching the end bursts and confirms. Keyboard users hold Enter instead.
API reference
Attributes
labelReact proplabelTypestringDefaultSlide to deployText in the track before confirming. Also used in the handle's aria-label, which is set on connect.
done-labelReact propdoneLabelTypestringDefaultDeployedText in the track after confirming; announced to screen readers.
hintReact prophintTypestringDefaultDrag the handle all the way, or hold EnterLine below the track.
done-hintReact propdoneHintTypestringDefaultDeploy started · productionLine below the track after confirming.
resetReact propresetTypenumberDefault2800Milliseconds before returning to the idle state after confirming. 0 or less keeps it confirmed until reset() is called.
Events
Events bubble and cross the shadow boundary unless the description says otherwise.
confirmReact proponConfirmDetail{}Fires once when the handle reaches the end, when it is released past 94% of the track, or when confirm() is called.
Methods
Call them on the element, for example through a React ref.
confirm()Confirms at once, as if the handle had reached the end. Does nothing if already confirmed.
reset()Returns to the idle state and restores hint.
Properties
label (read-only)TypestringThe label attribute, or Slide to deploy.
Keyboard
| Keys | Action |
|---|---|
| Enter / Space / ArrowRight (hold) | Slide the handle along while held; reaching the end confirms. Releasing early lets it spring back. |
Accessibility
- The handle is a native
<button>witharia-label<label>. Press and hold Enter to confirm. - A visually hidden
aria-live="polite"region announcesdone-labelwhen confirmed. - The track label is text marked
aria-hidden, since the handle'saria-labelalready carries it. - Reduced motion: the label shimmer and confirm sparks are off, the handle returns to the start at once instead of springing, and the hint changes without rolling.
Theming
The element reads your shadcn theme tokens through its shadow root, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
This component reads --foreground, --lumesec, --muted and --muted-foreground.
To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent, --ui-fg, --ui-muted and --ui-track.
Notes
- The component does not run the action; listen for
confirm. - The track is 58px tall and fills the host's width.
- The
resetattribute and thereset()method share a name; set the attribute withsetAttribute, not as a property.
Related
Was this page helpful?