Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                <form action="https://usebasin.com/f/xxxxxxxxxxxx" method="POST" id="contact-form">
  <div>
    <label for="name">First and Last Name</label>
    <input type="text" id="name" name="name" autofocus required>
  </div>
  <div>
    <label for="email">Email Address</label>
    <input type="email" id="email" name="email" required>
  </div>
  <div class="poof">
    <label for="organization">Organization</label>
    <input type="text" id="organization" name="organization">
  </div>
  <div>
    <label for="message">What's on your mind?</label>
    <textarea name="message" id="message" rows="10" required></textarea>
  </div>
  <div id="response-container"></div>
  <div>
    <div id="button-container">
      <button type="submit" id="send-button">
        Send Message
      </button>
      <div id="send-indicator" class="hide">
        <div></div>
        <div></div>
        <div></div>
      </div>
    </div>
  </div>
</form>
              
            
!

CSS

              
                #contact-form > div {
  margin: 20px 0;
}
#contact-form .poof {
  display: none;
}
#contact-form label {
  color: #4c566a;
  display: block;
  margin-bottom: 10px;
}
#contact-form input,
#contact-form textarea {
  border: 1px solid #d8dee9;
  border-radius: 5px;
  box-shadow: inset 1px 1px 2px #e5e9f0;
  padding: 12px;
  width: 500px;
}
@media only screen and (max-width: 600px) {
  #contact-form input,
  #contact-form textarea {
    width: 100%;
  }
}
#contact-form input:focus,
#contact-form textarea:focus,
#contact-form button:focus {
  outline: 2px solid #5e81ac;
  outline-offset: 2px;
}
#response-container {
  font-weight: bold;
}
#response-container.success {
  color: #a3be8c;
}
#response-container.error {
  color: #bf616a;
}
#button-container {
  background-color: #2e3440;
  border: none;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  display: inline-block;
  position: relative;
}
#send-button.hide,
#send-indicator.hide {
  visibility: hidden;
}
#send-button {
  background: none;
  border: none;
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  padding: 12px 20px;
}
#send-button:hover {
  background-color: #3b4252;
}
#send-indicator {
  display: flex;
  justify-content: center;
  position: absolute;
  top: 20%;
  left: 0;
  right: 0;
}
#send-indicator div {
  animation: 0.9s bounce infinite alternate;
  background: #fff;
  border-radius: 50%;
  margin: 0 3px;
  height: 7px;
  width: 7px;
}
#send-indicator div:nth-child(2) {
  animation-delay: 0.3s;
}
#send-indicator div:nth-child(3) {
  animation-delay: 0.6s;
}
@keyframes bounce {
  to {
    opacity: 0.3;
    transform: translate3d(0, 10px, 0);
  }
}

              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', sendContactFormToBasin);

function sendContactFormToBasin () {
  const contactForm = document.getElementById('contact-form');
  if (contactForm === null) {
    return;
  }
  contactForm.addEventListener('submit', whenContactFormSubmitted);
}

function whenContactFormSubmitted (event) {
  event.preventDefault();
  const contactForm = event.target;
  const formData = new FormData(contactForm);
  const xhr = new XMLHttpRequest();
  toggleSendButton();
  xhr.open('POST', contactForm.action, true);
  xhr.send(formData);
  xhr.addEventListener('load', whenContactFormSent);
}

function whenContactFormSent (event) {
  const xhr = event.target;
  const contactForm = document.getElementById('contact-form');
  const responseContainer = document.getElementById('response-container');
  if (responseContainer === null) {
    return;
  }
  if (xhr.status === 200) {
    responseContainer.classList.add('success');
    responseContainer.innerHTML = 'Message successfully sent.';
    contactForm.reset();
    toggleSendButton();
    setTimeout(resetResponseContainer, 5000, responseContainer);
  } else {
    let response = JSON.parse(xhr.response);
    responseContainer.classList.add('error');
    responseContainer.innerHTML = 'Error: ' + response.error;
    toggleSendButton();
  }
}

function toggleSendButton () {
  const sendButton = document.getElementById('send-button');
  const sendIndicator = document.getElementById('send-indicator');
  sendButton.classList.toggle('hide');
  sendIndicator.classList.toggle('hide');
}

function resetResponseContainer (responseContainer) {
  responseContainer.innerHTML = '';
  responseContainer.className = '';
}
              
            
!
999px

Console