Skip to content

VueClientRecaptcha

Canvas-based captcha component for Vue 3. Renders a random code with optional distortion and provides validation via v-model.

Overview

VueClientRecaptcha generates a random captcha code, displays it on a canvas, and validates user input. It supports themes, character presets, distortion options, and accessibility features.

Basic Usage

vue
<script setup>
import { ref } from 'vue'
import { VueClientRecaptcha } from 'vue-client-recaptcha'
import 'vue-client-recaptcha/dist/vue-client-recaptcha.css'

const input = ref('')
const valid = ref(false)
</script>

<template>
  <input v-model="input" placeholder="Enter captcha" />
  <VueClientRecaptcha v-model="input" v-model:valid="valid" />
</template>

Props Summary

PropTypeDefaultDescription
modelValuestring | null""User input (v-model)
charsPreset"alphanumeric" | "numeric" | "letters" | "custom""alphanumeric"Character preset
countnumber5Number of characters
theme"auto" | "light" | "dark""light"Theme mode
distortion"none" | "lines" | "dots" | "both""lines"Distortion type
simpleModebooleanfalseClean straight-line text

See Props API for the full list.

Events Summary

EventPayloadDescription
isValidbooleanValidation state changed
getCodestringCaptcha code on generate/refresh
refreshstringCaptcha regenerated
readyCanvas ready
errorunknownCanvas/context error

See Events API for details.

Slots

SlotDescription
iconCustom template for the refresh icon. Use your own icon component (e.g. FontAwesome), SVG, or plain text (e.g. "↻ Refresh"). When not used, the default is a refresh-style icon. You can also change it via the icon prop. See Slots API for examples.

Exposed Methods

MethodDescription
resetCaptcha()Regenerates the captcha

Example with custom icon

vue
<VueClientRecaptcha v-model="input" v-model:valid="valid">
  <template #icon>
    <span>↻ Refresh</span>
  </template>
</VueClientRecaptcha>