Form PasswordInput Component

Author: strittiCreated Apr 22, 2020Updated Oct 10, 2025
LabelsPriority: LowType: Feature requestType: Custom Component

Password Input which could toggle to show Password

It would be nice to have a Form PasswordInput Component which could toggle the visibility of the password. I created a simple one which may be integrated in the pool of components:

Excample

image

image

Source of Component

xml
<template>
   <div class="input-group">
      <input class="form-control"
        @input="handleInput"
        v-model="password"
        :type="showPassword ? 'text' : 'password'"
        v-bind:placeholder="placeholder" autocomplete="true"/>
      <div class="input-group-append">
          <div :class="{'cursor-pointer':showPointer}"
                @click="showPassword = !showPassword"
                @mouseout="showPointer = false"
                @mouseover="showPointer = true"
                class="input-group-text">
            <b-icon-eye v-if="! showPassword"/>
            <b-icon-eye-fill v-if="showPassword"/>
          </div>
      </div>
  </div>
</template>
<script>
import { BIconEye, BIconEyeFill } from 'bootstrap-vue'
export default {
  name: 'PasswordInput',
  props: {
    placeholder: String,
    value: String
  },
  data () {
    return {
      showPassword: false,
      showPointer: false,
      password: this.value
    }
  },
  components: {
    BIconEye,
    BIconEyeFill
  },
  methods: {
    handleInput (e) {
      this.$emit('input', this.password)
    }
  }
}
</script>

Source: bootstrap-vue/bootstrap-vue