Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<div class="heading">
  <h1>Vue.js Password Generator</h1>
  <h4>A simple example creating a password generator using Vue.js v2.x.</h4>
</div>

<div class="container" id="app">
  
  <div class="row">
    <div class="col-sm-12">
      <div class="form-group">
        <vue-password size="45" auto="true" class=""></vue-password>
      </div>
    </div>
  </div>
  
  <br />
  
  <h2>Script Demo</h2><hr>

  <div class="form-group">
    <label class="text-muted">Using all of the character sets:</label>
    <vue-password size="24" auto="true" characters="a-z,A-Z,0-9,#"></vue-password>
  </div>

  <div class="form-group">
    <label class="text-muted">Using both the a-z and A-Z character sets:</label>
    <vue-password size="24" auto="true" characters="a-z,A-Z"></vue-password>
  </div>

  <div class="form-group">
    <label class="text-muted">Using only the A-Z character set:</label>
    <vue-password size="24" auto="true" characters="A-Z"></vue-password>
  </div>

  <div class="form-group">
    <label class="text-muted">Using only the a-z character set:</label>
    <vue-password size="24" auto="true" characters="a-z"></vue-password>
  </div>

  <div class="form-group">
    <label class="text-muted">Using only the number character set:</label>
    <vue-password size="24" auto="true" characters="0-9"></vue-password>
  </div>
  
  <br />

  <h2>How It Works</h2><hr>
  <dl class="dl-horizontal">

    <dt>Characters<br><small>Is Optional</small></dt><dd>The <strong>characters</strong> attribute is used to set the character type used in the password. You can use numbers <code>0-9</code>, letters <code>a-z</code> (and or) <code>A-Z</code>, and spical characters <code>#</code>. All of these sets can be used individually, but they all work together too.</dd><br>

    <dt>Size<br><small>Is Optional</small></dt><dd>The <strong>size</strong> attribute is used to set the number of characters that is used in the field, if you need a password with 12 characters, then set this attribute to 12.</dd><br>

    <dt>Type<br><small>Is Optional</small></dt><dd>The <strong>type</strong> attribute is used to change the field type from <code>text</code> to <code>password</code>.</dd><br>

    <dt>Placeholder<br><small>Is Optional</small></dt><dd>The <strong>placeholder</strong> attribute is used to set the place holder text on the field input.</dd><br>

    <dt>Auto<br><small>Is Optional</small></dt><dd>The <strong>auto</strong> attribute is used to suppress the automatic generation of the password on load, if you don't want the field to automatically generate the password on load, then pass <code>false</code> to the component.</dd>
  </dl>
  
</div>

              
            
!

CSS

              
                $purple: #5c4084;

body {
  background-color: $purple;
  padding: 50px;
}
.container {
  padding: 40px 80px 15px 80px;
  background-color: #fff;
  border-radius: 8px;
  max-width: 800px;
}
.heading {
  text-align: center;
  h1 {
    background: -webkit-linear-gradient(#fff, #999);
    -webkit-text-fill-color: transparent;
    -webkit-background-clip: text;
    text-align: center;
    margin: 0 0 5px 0;
    font-weight: 900;
    font-size: 4rem;
    color: #fff;
  }
  h4 {
    color: lighten(#5c3d86,30%);
    text-align: center;
    margin: 0 0 35px 0;
    font-weight: 400;
    font-size: 24px;
  }
}
.btn{
  outline: none !important;
}
.btn.btn-primary {
  background-color: $purple;
  border-color: $purple;
  outline: none;
  &:hover {
    background-color: darken($purple, 10%);
    border-color: darken($purple, 10%);
  }
  &:active, &:focus {
    background-color: lighten($purple, 5%);
    border-color: lighten($purple, 5%);
  }
  & .fa {
    padding-right: 4px;
  }
}
.label-primary {
  background-color: $purple;
  display: inline-block;
  font-size: 15px;
  font-weight: normal;
}
.form-group {
  margin-bottom: 25px;
}
small {
  font-weight: normal;
  color: #b4bcc3;
}
              
            
!

JS

              
                
Vue.component('vue-password', {
  template: '<div class="input-group"><span class="input-group-addon"><span class="fa fa-lock"></span></span><input :type="type" class="form-control" :placeholder="placeholder" :value="password" /><span class="input-group-btn"><button type="button" class="btn btn-primary" @click="generate()"><span class="fa fa-refresh"></span></button></span></div>',
  props : {
    type: {
      type: String,
      default: 'text'
    },
    size: {
      type: String,
      default: '32'
    },
    characters: {
      type: String,
      default: 'a-z,A-Z,0-9,#'
    },
    placeholder: {
      type: String,
      default: 'Password'
    },
    auto: [String, Boolean],
    value: ''
  },
  data: function() {
    return {
      password: this.value
    }
  },
  mounted: function() {
    if(this.auto == 'true' || this.auto == 1) {
      this.generate();
    }
  },
  methods: {
    
    generate () {
      let charactersArray = this.characters.split(',');  
      let CharacterSet = '';
      let password = '';
      
      if( charactersArray.indexOf('a-z') >= 0) {
        CharacterSet += 'abcdefghijklmnopqrstuvwxyz';
      }
      if( charactersArray.indexOf('A-Z') >= 0) {
        CharacterSet += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      }
      if( charactersArray.indexOf('0-9') >= 0) {
        CharacterSet += '0123456789';
      }
      if( charactersArray.indexOf('#') >= 0) {
        CharacterSet += '![]{}()%&*$#^<>~@|';
      }
      
      for(let i=0; i < this.size; i++) {
        password += CharacterSet.charAt(Math.floor(Math.random() * CharacterSet.length));
      }
      this.password = password;
    }
    
  }
});

new Vue({
  el: '#app'
});

              
            
!
999px

Console