Skip to content

SlideVerify

Slide verification component for human-machine verification scenarios.

Component Types

Basic Usage

html
<wd-slide-verify @success="handleSuccess" @fail="handleFail" />
ts
const toast = useToast()

function handleSuccess() {
  toast.success('Verification successful')
}

function handleFail() {
  toast.error('Verification failed, please try again')
}

Component States

Disabled State

Set disabled to disable slide verification.

html
<wd-slide-verify disabled />

Component Styles

Custom Text

Customize prompt text through text and success-text properties.

html
<wd-slide-verify text="Please drag the slider" success-text="Verification successful" />

Custom Colors

Customize colors through background-color and active-background-color properties.

html
<wd-slide-verify background-color="#E8F4FF" active-background-color="#4D94FF" />

Custom Icons

Customize icons through icon and success-icon properties.

html
<wd-slide-verify icon="arrow-right" success-icon="thumb-up-fill" />

Special Styles

Custom Tolerance Range

Set the tolerance range (in px) through the tolerance property, default is 10px.

html
<wd-slide-verify :tolerance="20" />

Reset Method

Get the component instance through ref and call the reset method to reset the verification state.

html
<wd-slide-verify ref="slideVerifyRef" @success="handleSuccess" @fail="handleFail" />
<wd-button type="primary" @click="handleReset">Reset</wd-button>
ts
import { ref } from 'vue'
import type { SlideVerifyInstance } from '@/uni_modules/wot-ui/components/wd-slide-verify/types'

const slideVerifyRef = ref<SlideVerifyInstance>()

function handleReset() {
  slideVerifyRef.value?.reset()
}

Slot Usage

Supports customizing content through slots.

html
<wd-slide-verify>
  <template #text>
    <text>Slide right to complete verification</text>
  </template>
  <template #success-text>
    <text>Verification passed</text>
  </template>
  <template #icon>
    <view>ICON</view>
  </template>
  <template #success-icon>
    <view style="color: red">OK</view>
  </template>
</wd-slide-verify>

Attributes

ParameterDescriptionTypeDefault Value
toleranceTolerance range, unit is pxnumber10
textPrompt text, displays built-in text when emptystring''
success-textVerification success prompt text, displays built-in text when emptystring''
disabledWhether to disablebooleanfalse
background-colorBackground colorstring-
active-background-colorBackground color when activestring-
iconSlider icon namestringdouble-right
success-iconSuccess icon namestringcheck-circle-fill
icon-sizeIcon sizestring / number-
success-icon-sizeSuccess icon sizestring / number-

Events

Event NameDescriptionParameters
successTriggered when verification succeeds-
failTriggered when verification fails-

Methods

Method NameDescriptionParameters
initInitialize size information-
resetReset verification component to initial state-

Slots

NameDescription
textCustom prompt text content
success-textCustom verification success prompt text content
iconCustom slider icon
success-iconCustom success icon

External Style Classes

Class NameDescription
custom-classRoot node style class
custom-styleRoot node style

主题定制

CSS 变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 全局配置

名称默认值描述
--wot-slide-verify-height$n-40组件高度
--wot-slide-verify-width100%组件宽度
--wot-slide-verify-bg$filled-bottom组件背景色
--wot-slide-verify-radius$radius-large圆角
--wot-slide-verify-track-bg$success-main成功态track背景色
--wot-slide-verify-disabled-opacity$opacity-disabled禁用态透明度
--wot-slide-verify-text-color$text-main提示文字颜色
--wot-slide-verify-text-font-size$typography-label-size-main提示文字字号
--wot-slide-verify-text-line-height$typography-label-line--height-size-main提示文字行高
--wot-slide-verify-success-text-color$text-white成功态文字颜色
--wot-slide-verify-button-bg$filled-oppo滑块背景色
--wot-slide-verify-button-shadow$n-0 $n-2 $n-8 $opac-4_15滑块阴影色
--wot-slide-verify-button-color$icon-secondary滑块图标颜色
--wot-slide-verify-button-success-color$success-main滑块图标成功态颜色
--wot-slide-verify-button-size$slide-verify-height滑块尺寸
--wot-slide-verify-button-border-color$border-light滑块边框颜色
--wot-slide-verify-success-icon-size$n-20滑块图标尺寸

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.