SliderCaptcha
Slide the piece into the gap: a human check
A small puzzle before a form is sent: drag the handle until the loose piece fits the gap. It filters casual bots and mistakes, and it is nice to use on a phone. Enable your submit button with v-model:verified.
<template>
<div class="col" style="max-width: 360px">
<BlessSliderCaptcha
ref="captcha"
v-model:verified="verified"
src="/hero-light.png"
@verify="took = $event.ms"
/>
<BlessButton :disabled="!verified">Send</BlessButton>
<small v-if="verified">Solved in {{ took }} ms.</small>
<BlessButton v-if="verified" variant="ghost" size="sm" @click="captcha?.reset()"
>Try again</BlessButton
>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { BlessButton, BlessSliderCaptcha } from "blessing-ui";
const verified = ref(false);
const captcha = ref<InstanceType<typeof BlessSliderCaptcha>>();
const took = ref<number | null>(null);
</script>Not security
Everything runs in the browser, so a script can skip it. Treat it as a speed bump: always check the real submission on the server (rate limits, a server-side challenge, or a service built for the job). The verify event gives you how long the solve took (ms) if you want to send that along as a weak signal.
Not accessible on its own
The puzzle needs sight. Keyboard users can solve it (← → move the piece, Shift for bigger steps, Enter to submit), but a screen-reader user cannot see the gap. Offer another way through (an email link, a text challenge) next to it.
- A miss resets the slider and moves the gap, so there is nothing to learn from a failed try.
toleranceis how close counts, as a fraction of the track (default0.03). - Pass
srcfor a picture to cut the piece from. Without it a checker pattern is drawn from the theme colors. The widget fills its container up to 360 px. - Once solved it stays locked until
reset()(exposed) is called.
Usage
import { BlessSliderCaptcha } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
src | string | — | background picture; without it a checker pattern is drawn |
tolerance | number | 0.03 | how close counts, as a fraction of the track (0.03 = 3%) |
label | string | "Slide the piece into the gap" | |
labels | Partial<{ verified: string; failed: string; }> | — | what is announced when the piece lands or misses |
verified | boolean | false | true once solved; the widget then stays locked until `reset()` |
Events
| Name | Payload | Description |
|---|---|---|
fail | [] | |
update:verified | [value: boolean] | |
verify | [info: { ms: number; }] |
Exposed
| Name | Type | Description |
|---|---|---|
reset | () => void |