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

              
                <svg aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <symbol id="volume" viewBox="0 0 34 32">
    <title>Volume Enabled</title>
    <path fill="currentColor" d="M27.814 28.814c-0.384 0-0.768-0.146-1.061-0.439-0.586-0.586-0.586-1.535 0-2.121 2.739-2.739 4.247-6.38 4.247-10.253s-1.508-7.514-4.247-10.253c-0.586-0.586-0.586-1.536 0-2.121s1.536-0.586 2.121 0c3.305 3.305 5.126 7.7 5.126 12.374s-1.82 9.069-5.126 12.374c-0.293 0.293-0.677 0.439-1.061 0.439zM22.485 25.985c-0.384 0-0.768-0.146-1.061-0.439-0.586-0.586-0.586-1.535 0-2.121 4.094-4.094 4.094-10.755 0-14.849-0.586-0.586-0.586-1.536 0-2.121s1.536-0.586 2.121 0c2.55 2.55 3.954 5.94 3.954 9.546s-1.404 6.996-3.954 9.546c-0.293 0.293-0.677 0.439-1.061 0.439v0zM17.157 23.157c-0.384 0-0.768-0.146-1.061-0.439-0.586-0.586-0.586-1.535 0-2.121 2.534-2.534 2.534-6.658 0-9.192-0.586-0.586-0.586-1.536 0-2.121s1.535-0.586 2.121 0c3.704 3.704 3.704 9.731 0 13.435-0.293 0.293-0.677 0.439-1.061 0.439z" />
    <path fill="currentColor" d="M13 30c-0.26 0-0.516-0.102-0.707-0.293l-7.707-7.707h-3.586c-0.552 0-1-0.448-1-1v-10c0-0.552 0.448-1 1-1h3.586l7.707-7.707c0.286-0.286 0.716-0.372 1.090-0.217s0.617 0.519 0.617 0.924v26c0 0.404-0.244 0.769-0.617 0.924-0.124 0.051-0.254 0.076-0.383 0.076z" />
  </symbol>
  
  <symbol id="muted" viewBox="0 0 32 32">
    <title>Volume Muted</title>
    <path fill="currentColor" d="M30 19.348v2.652h-2.652l-3.348-3.348-3.348 3.348h-2.652v-2.652l3.348-3.348-3.348-3.348v-2.652h2.652l3.348 3.348 3.348-3.348h2.652v2.652l-3.348 3.348 3.348 3.348z" />
    <path fill="currentColor" d="M13 30c-0.26 0-0.516-0.102-0.707-0.293l-7.707-7.707h-3.586c-0.552 0-1-0.448-1-1v-10c0-0.552 0.448-1 1-1h3.586l7.707-7.707c0.286-0.286 0.716-0.372 1.090-0.217s0.617 0.519 0.617 0.924v26c0 0.404-0.244 0.769-0.617 0.924-0.124 0.051-0.254 0.076-0.383 0.076z" />
  </symbol>
  
  <symbol id="valid" viewBox="0 0 32 32">
    <title>Input Valid</title>
    <path fill="currentColor" d="M27 4l-15 15-7-7-5 5 12 12 20-20z"></path>
  </symbol>
</svg>

<form action="/" method="POST">
  <header>
    <button type="button" class="microphone" data-mute>
      <svg width="20" height="20">
        <use xlink:href="#muted"></use>
      </svg>
    </button>
    
    <div id="progress-bar">
      <div id="progress-bar-inner"></div>
    </div>
  </header>
  
  
  <div class="container">
    <div class="slider">
      <section class="section" data-section data-message="Hey there! Welcome to the sign up form for our amazing app. I will assist you to create a new account. If you don't want my help, you can mute me at any time with the button that is on top of the form. To start, click the button below.">
        <h1>Hey there! Welcome to our amazing app. Are you ready to sign up?</h1>
        <button type="button" class="button is-purple" data-action="next">Yes, let's start!</button>
      </section>

      <section class="section is-hidden" data-section data-message="Alright, let's begin. I need your first name, so please write it into the text field and click next when you have finished.">
        <label for="firstname">Let's start by entering your first name: <span class="required">*</span></label>
        
        <div class="form-group">
          <input type="text" class="form-control" id="firstname" name="firstname" required placeholder="e.g. John" data-error-message="This field can't be empty, please enter your first name.">
          <svg class="form-addon" width="20" height="20">
            <use xlink:href="#valid"></use>
          </svg>
        </div>
        
        <!--<button type="button" class="button is-purple" data-action="prev">Back</button>-->
        <button type="button" class="button is-purple" data-action="next">Next</button>
      </section>

      <section class="section is-hidden" data-section data-message="I also need your last name, so please write it into the text field and click on next.">
        <label for="lastname">Now, tell us your last name: <span class="required">*</span></label>
        
        <div class="form-group">
          <input type="text" class="form-control" id="lastname" name="lastname" required placeholder="e.g. Smith" data-error-message="This field can't be empty, please enter your last name.">
          <svg class="form-addon" width="20" height="20">
            <use xlink:href="#valid"></use>
          </svg>
        </div>
        
        <button type="button" class="button is-gray" data-action="prev">Back</button>
        <button type="button" class="button is-purple" data-action="next">Next</button>
      </section>

      <section class="section is-hidden" data-section data-message="You'll need a username to use our app. I have already created one for you, but you can change it now if you don't like it. Click next after you are done.">
        <label for="username">Create a unique username: <span class="required">*</span></label>
        
        <div class="form-group">
          <input type="text" class="form-control" id="username" name="username" required placeholder="e.g. john.doe" data-error-message="This field can't be empty, please enter your username with at least 4 characters." pattern=".{4,}" data-hook="setUsername">
          <svg class="form-addon" width="20" height="20">
            <use xlink:href="#valid"></use>
          </svg>
        </div>
        
        <p class="form-help">We have automatically created a username based on your first and last name. You can change it if you'd like.</p>
        
        <button type="button" class="button is-gray" data-action="prev">Back</button>
        <button type="button" class="button is-purple" data-action="next">Next</button>
      </section>

      <section class="section is-hidden" data-section data-message="Let's get to the important stuff. Please enter a password into the text field that is as secure as possible. Safe passwords consist of 8 or more characters with numbers, letters from the alphabet and special characters.">
        <label for="password">Think of a secure password: <span class="required">*</span></label>
        
        <div class="form-group">
          <input type="password" class="form-control" id="password" name="password" required data-error-message="Please enter a valid password that has at least 8 characters." pattern=".{8,}">
          <svg class="form-addon" width="20" height="20">
            <use xlink:href="#valid"></use>
          </svg>
        </div>
        
        <div id="password-strength-meter">
          <div id="password-strength-meter-inner"></div>
        </div>
        
        <p class="form-help">The password should have at least 8 characters and consist of letters and numbers. Include special characters to make it even more unbreakable!</p>
        
        <button type="button" class="button is-gray" data-action="prev">Back</button>
        <button type="button" class="button is-purple" data-action="next">Next</button>
      </section>

      <section class="section is-hidden" data-section data-message="Now I need to make sure that I've got your password correctly, so please type it again and than press next.">
        <label for="password_confirmation">Please re-enter your password: <span class="required">*</span></label>
        
        <div class="form-group">
          <input type="password" class="form-control" id="password_confirmation" name="password_confirmation" required data-error-message="You didn't match your password, please retry." pattern=".{8,}">
          <svg class="form-addon" width="20" height="20">
            <use xlink:href="#valid"></use>
          </svg>
        </div>
        
        <button type="button" class="button is-gray" data-action="prev">Back</button>
        <button type="button" class="button is-purple" data-action="next">Next</button>
      </section>

      <section class="section is-hidden" data-section data-message="Finally, as the last step, I need to know your email address, so that I can send you the confirmation and other important information. Write it into the text field and click next once you are done.">
        <label for="email">Finally, we need your email address: <span class="required">*</span></label>
        
        <div class="form-group">
          <input type="email" class="form-control" id="email" name="email" required placeholder="e.g. john.doe@gmail.com" data-error-message="Please enter a valid email address.">
          <svg class="form-addon" width="20" height="20">
            <use xlink:href="#valid"></use>
          </svg>
        </div>
        
        <button type="button" class="button is-gray" data-action="prev">Back</button>
        <button type="button" class="button is-purple" data-action="next">Next</button>
      </section>

      <section class="section is-hidden" data-section data-message="Congratulations! You have done it! To create your account, just click on the button below that says 'Sign Up' and I will handle the rest. See you soon!">
        <h2>Ready to sign you up!</h2>
        <p>That's it, we have gathered all the required information to create your account.</p>
        <p>After you click the below button, we'll send you an email confirmation with all the details.</p>
        
        <button type="button" class="button is-gray" data-action="prev">Back</button>
        <button type="submit" class="button is-red">Sign Up!</button>
      </section>
    </div>
  </div>
</form>

<footer id="footer">
  <p>This demo was only tested and might only work in Chrome. Voice support and interactions might not work in other browsers!</p>
  
  <p>Copyright (c) 2018 by Andreas Remdt</p>
</footer>
              
            
!

CSS

              
                //
// Variables
// --------------------------------
$purple: #B978C8;
$red: #F27D86;
$blue: #9379F8;
$green: #71CF6E;
$light-gray: #EAEFF3;
$text-color-blue: #30304C;
$text-color-gray: #807F91;

$fallback: system-ui, BlinkMacSystemFont, -apple-system, Segoe UI ,Roboto, "Fira Sans", Helvetica Neue, sans-serif;



//
// General styles
// --------------------------------
:root {
  font: 400 18px/1.5 "Open Sans", $fallback;
}

* {
  box-sizing: border-box;
}

h1, h2, label {
  font-family: "Nunito", $fallback;
  font-weight: 700;
  color: $text-color-blue;
}

h1, h2 {
  line-height: 1.25;
}

p {
  color: $text-color-gray;
}

html {
  min-height: 100vh;
  background: linear-gradient(to right bottom, $red, $purple, $blue) center/cover no-repeat;
}



//
// The main wrapper
// --------------------------------
form {
  width: 35rem;
  margin: 3rem auto;
  background-color: white;
  border-radius: .5rem;
  box-shadow: 0 5px 20px rgba(0, 0, 0, .3);
  text-align: center;
  position: relative;
  min-height: 25rem;
  animation: fade-in .4s ease-out forwards;
}



//
// Buttons
// --------------------------------
.button {
  border: none;
  border-radius: .3rem;
  padding: .7rem 2.5rem;
  color: white;
  font-size: 85%;
  box-shadow: 0 17px 15px -10px rgba(0, 0, 0, .2);
  outline: none;
  text-transform: uppercase;
  margin-top: 1rem;
  font-family: inherit;
  transition: box-shadow .1s linear;
  
  &.is-purple {
    background: linear-gradient(to right, #A972CF, #7052AC);
    
    &:hover {
      background: linear-gradient(to right, darken(#A972CF, 5%), darken(#7052AC, 5%));
      box-shadow: 0 24px 20px -15px rgba(0, 0, 0, 0.2);
    }
    
    &:focus {
      background: linear-gradient(to right, darken(#A972CF, 10%), darken(#7052AC, 10%));
      box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
    }
  }
  
  &.is-gray {
    background: linear-gradient(to right, $light-gray, darken($light-gray, 10%));
    color: $text-color-gray;
    
    &:hover {
      background: linear-gradient(to right, darken($light-gray, 5%), darken($light-gray, 15%));
      box-shadow: 0 24px 20px -15px rgba(0, 0, 0, 0.2);
      color: white;
    }
    
    &:focus {
      background: linear-gradient(to right, darken($light-gray, 10%), darken($light-gray, 20%));
      box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
      color: white;
    }
  }
  
  &.is-red {
    background-color: $red;
    
    &:hover {
      background-color: darken($red, 5%);
      box-shadow: 0 24px 20px -15px rgba(0, 0, 0, 0.2);
    }
    
    &:focus {
      background-color: darken($red, 10%);
      box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
    }
  } 
}

.microphone {
  background-color: white;
  box-shadow: 0 3px 5px rgba(0, 0, 0, .2);
  color: $text-color-blue;
  margin: 0;
  border: 0;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  transform: translateY(-1.75rem);
  outline: none;
  transition: all .1s linear;
  
  &:hover, &:focus {
    background-color: #EAEFF3;
    box-shadow: 0 13px 15px -5px rgba(0, 0, 0, .2);
  }
}



//
// Form elements
// --------------------------------
.form-group {
  position: relative;
}

.form-help {
  margin: 0;
  font-size: 80%;
  color: #C0C0C8;
}

.form-error {
  margin: 0;
  font-size: 80%;
  color: $red;
}

.required {
  color: $red;
}

.form-addon {
  position: absolute;
  right: 1rem;
  top: .85rem;
  color: $green;
  opacity: 0;
  transition: opacity .2s linear;
}

.form-control {
  border: 1px solid #fff;
  border-radius: .3rem;
  padding: .8rem 1rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .14);
  width: 100%;
  outline: none;
  margin-bottom: .4rem;
  color: $text-color-gray;
  font-family: inherit;
  transition: box-shadow .1s linear;
  
  &:hover, &:focus {
    box-shadow: 0 7px 15px -3px rgba(0, 0, 0, 0.2);
  }
  
  &:valid + .form-addon {
    opacity: 1;
  }
}

label {
  margin-bottom: 2rem;
  font-size: 1.2rem;
  display: block;
}



//
// Layout
// --------------------------------
.container {
  overflow: hidden;
  
  > .slider {
    display: flex;
    transition: transform .25s ease-out;
  }
}

.section {
  padding: 2rem;
  flex: 0 0 35rem;
}



//
// Progress Bar
// --------------------------------
#progress-bar {
  width: 100%;
  height: .2rem;
  background-color: $light-gray;
  position: relative;
}

#progress-bar-inner {
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  transition: width .2s ease-out;
  background: linear-gradient(to right, $red, $purple);
}



//
// Meter Bar
// --------------------------------
#password-strength-meter {
  width: 70%;
  background-color: $light-gray;
  height: .3rem;
  margin: 1rem auto;
  
  &[data-strength="1"] #password-strength-meter-inner {
    width: 25%;
    background-color: $red;
  }
  
  &[data-strength="2"] #password-strength-meter-inner {
    width: 50%;
    background-color: orange;
  }
  
  &[data-strength="3"] #password-strength-meter-inner {
    width: 75%;
    background-color: #C6B453;
  }
  
  &[data-strength="4"] #password-strength-meter-inner {
    width: 100%;
    background-color: $green;
  }
}

#password-strength-meter-inner {
  background-color: transparent;
  height: 100%;
  transition: width .2s ease-out, background-color .1s linear;
}



//
// Footer
// --------------------------------
#footer {
  position: fixed;
  bottom: 0;
  background-color: white;
  padding: 0 1rem;
  font-size: 80%;
  width: 100%;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, .3);
}



//
// Keyframes
// --------------------------------
@keyframes fade-in {
  0% {
    transform: translateY(1rem);
    opacity: 0;
  }
  
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}
              
            
!

JS

              
                document.addEventListener("DOMContentLoaded", function() {
  var buttons = document.querySelectorAll("button[data-action='next']"),
      buttonsPrev = document.querySelectorAll("button[data-action='prev']"),
      sections = document.querySelectorAll("section[data-section]"),
      buttonMute = document.querySelector("button[data-mute]"),
      inputs = document.querySelectorAll("input"),
      slider = document.querySelector(".slider"),
      form = document.querySelector("form"),
      progress = document.getElementById("progress-bar-inner"),
      passwordField = document.getElementById("password"),
      meter = document.getElementById("password-strength-meter"),
      speakingEnabled = localStorage.getItem("speakingEnabled") || false,
      index = 0;
  
  
  
  handleNextSlide();
  updateMuteButton();
  
  
  /**
   * If the validation passes, handles all the logic
   * to show the next slide. Sets the focus to the next input,
   * reads the text, updates the progress bar and more.
   */
  function handleNextSlide() {
    if (index <= sections.length - 1) {
      
      responsiveVoice.cancel();
      
      if (index > 1 && !inputIsValid(sections[index - 1])) {
        return false;
      }
      
      setFocus(sections[index]);
      speak(sections[index].dataset.message);
      showNextSlide();
      updateProgress();
    
      index++;
    }
  }
  
  
  
  
  /**
   * Goes back one slide and sets the index accordingly.
   */
  function handlePrevSlide() {
    responsiveVoice.cancel();
    
    slider.style.transform = `translateX(-${35 * (index - 2)}rem)`;
    
    index--;
  }
  
  
  
  /**
   * Updates the progress bar on the top
   * to inform the user about how much slides
   * are missing.
   */
  function updateProgress() {
    progress.style.width = `${index * 100 / (sections.length - 1)}%`;
  }
  
  
  
  /**
   * Checks whether a input is valid or not.
   * 
   * @return boolean Returns true if input passes all tests
   *    or false if there are any errors.
   */
  function inputIsValid(section) {
    var input = section.querySelector("input");
    
    if (!input || input.checkValidity()) {
      return true;
    }
    
    showError(input);
  }
  
  
  
  /**
   * Shows validation errors below the input
   * to the user.
   */
  function showError(input) {
    if (!input.nextElementSibling.classList.contains("form-error")) {
      var message = document.createElement("p");
    
      message.className = "form-error";
      message.textContent = input.dataset.errorMessage;

      input.parentNode.insertBefore(message, input.nextSibling);
      
      speak(input.dataset.errorMessage);
    }
  }
  
  
  
  /**
   * Shows the next slide by moving the slide container
   * to the left. All slides are aligned next to each other
   * horizontally.
   */
  function showNextSlide() {
    if (index > 0) {
      slider.style.transform = `translateX(-${35 * index}rem)`;
    }
  }
  
  
  
  /**
   * Sets the focus to the following input after 500ms and checks
   * if there's a registered hook. If the there is one,
   * execute it.
   */
  function setFocus(section) {
    var input = section.querySelector("input");
    
    if (input) {
      setTimeout(() => input.focus(), 500);
      
      switch(input.dataset.hook) {
        case "setUsername":
          setUsername();
          break;
      }
    }
  }
  
  
  
  /**
   * Sets the username based on the user's first
   * and last name, like this:
   *
   * `firstname.lastname`
   */
  function setUsername() {
    var firstname = document.getElementById("firstname").value.trim().split(/\s/)[0].toLowerCase(),
        lastname = document.getElementById("lastname").value.trim().split(/\s/)[0].toLowerCase(),
        username = document.getElementById("username"); 
    
    username.value = `${firstname}.${lastname}`;
  }
  
  
  
  /**
   * Speaks to the user using responsiveVoiceJS and the
   * HTML5 Web Speech API.
   * Only speaks when the user enabled this features.
   */
  function speak(text) {
    if (speakingEnabled == "true") {
      responsiveVoice.speak(text, "UK English Male");
    }
  }
  
  
  
  /**
   * Enables / disables the speech support.
   * The configuration is persisted in localStorage.
   */
  function toggleSpeaking() {
    speakingEnabled = !speakingEnabled;
    
    localStorage.setItem("speakingEnabled", speakingEnabled);
    
    updateMuteButton();
    
    if (!speakingEnabled) {
      responsiveVoice.cancel();
    }
  }
  
  
  
  /**
   * Updates the mute button's icon.
   */
  function updateMuteButton() {
    buttonMute.querySelector("use").setAttribute("xlink:href", `${localStorage.getItem("speakingEnabled") == "true" ? "#volume" : "#muted"}`);
  }
  
  
  
  /**
   * Prevents the form from submitting.
   */
  function handleSubmit(event) {
    event.preventDefault();
  }
  
  
  
  /**
   * Shows the password strength to the user
   * using the zxcvbn library from Dropbox.
   */
  function indicatePasswordStrength() {
    var result = zxcvbn(this.value);

    meter.dataset.strength = result.score;
  }
  
  
  
  /**
   * Prevents the form from submitting when the user
   * presses the Enter key. Instead clicks the `Next` button.
   */
  function handleKeyPress(event) {
    if (event.keyCode === 13) {
      event.preventDefault();
      
      this.parentNode.parentNode.querySelector("button").click();
    }
  }
  
  
  
  /**
   * Registers all event listeners.
   */
  buttons.forEach(button => button.addEventListener("click", handleNextSlide));
  buttonsPrev.forEach(button => button.addEventListener("click", handlePrevSlide));
  buttonMute.addEventListener("click", toggleSpeaking);
  form.addEventListener("submit", handleSubmit);
  password.addEventListener("input", indicatePasswordStrength);
  inputs.forEach(input => input.addEventListener("keypress", handleKeyPress));
});
              
            
!
999px

Console