Skip to content

PasswordInput ​

A grid input box component that can be used for inputting passwords, SMS verification codes, and other scenarios. Usually used in conjunction with the number keyboard component.

Basic Usage ​

Use with the number keyboard component to implement password input functionality.

html
<!-- Password input box -->
<wd-password-input v-model="value" :focused="showKeyboard" @focus="showKeyboard = true" />
<!-- Number keyboard -->
<wd-number-keyboard v-model="value" v-model:visible="showKeyboard" :maxlength="4" @blur="showKeyboard = false" />
typescript
import { ref } from 'vue'

const value = ref<string>('123')
const showKeyboard = ref<boolean>(true)

Custom Length ​

Set the password length through the length property.

html
<!-- Password input box -->
<wd-password-input v-model="value" :length="4" :focused="showKeyboard" @focus="showKeyboard = true" />
<wd-number-keyboard v-model="value" v-model:visible="showKeyboard" :maxlength="4" @blur="showKeyboard = false"></wd-number-keyboard>

Grid Spacing ​

Set the spacing between grids through the gutter property.

html
<!-- Password input box -->
<wd-password-input v-model="value" :gutter="10" :focused="showKeyboard" @focus="showKeyboard = true" />

Plain Text Display ​

Set mask to false to display the input content in plain text, suitable for SMS verification code scenarios.

html
<!-- Password input box -->
<wd-password-input v-model="value" :mask="false" :focused="showKeyboard" @focus="showKeyboard = true" />

Information Tips ​

Set prompt information through the info property and error prompt through the error-info property, for example, prompting password error when six digits are entered.

html
<!-- Password input box -->
<wd-password-input v-model="value" info="Password is 6 digits" :error-info="errorInfo" :focused="showKeyboard" @focus="showKeyboard = true" />
<!-- Number keyboard -->
<wd-number-keyboard v-model="value" :show="showKeyboard" :maxlength="6" @blur="showKeyboard = false" />
typescript
import { ref, watch } from 'vue'

const value = ref('123')
const errorInfo = ref('')
const showKeyboard = ref(true)

watch(value, (newVal) => {
  if (newVal.length === 6 && newVal !== '123456') {
    errorInfo.value = 'Incorrect password'
  } else {
    errorInfo.value = ''
  }
})

Attributes ​

ParameterDescriptionTypeOptionsDefaultVersion
v-modelPassword valuestring---
infoText prompt below input boxstring---
error-infoError prompt below input boxstring---
lengthMaximum password lengthnumber-6-
gutterSpacing between input box grids, like 20px 2em, default unit is pxnumber / string-0-
maskWhether to hide password contentboolean-true-
focusedWhether focused, cursor will be displayed when focusedboolean-false-

Events ​

Event NameDescriptionParametersVersion
focusTriggered when input box is focusedevent:Event-

Source Code ​

Documentation
• Component

Released under the MIT License.

Released under the MIT License.