Pen Settings

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

  <input type="checkbox" id="json-toggle" class="toggle">
  <label for="json-toggle">JSON Mode</label>

  <div class="form">
    <div class="fieldset fieldset__options">
      <label>Select a transition</label>
      <label><input type="radio" name="transition" value="1" checked="checked"><code>linear 500ms</code></label>
      <label><input type="radio" name="transition" value="2"><code>linear 200ms</code></label>
      <label><input type="radio" name="transition" value="3"><code>ease 300ms</code></label>
      <label><input type="radio" name="transition" value="4"><code>ease-in 300ms</code></label>
      <label><input type="radio" name="transition" value="5"><code>ease-out 300ms</code></label>
      <label><input type="radio" name="transition" value="6"><code>cubic-bezier(.05, .69, .14, 1) 500ms</code></label>
      <label><input type="radio" name="transition" value="custom">Custom</label>
    <div class="fieldset">
      <label for="id">Custom transition (timing speed)</label>
      <input type="text" placeholder="e.g. cubic-bezier(.03,.43,.95,.66) 500ms" name="custom-transition" value="cubic-bezier(.03,.43,.95,.66) 500ms">
    <div class="fieldset">
      <label for="id">Some other field</label>
      <input type="text">
    <div class="fieldset">
      <label for="id">Some other field</label>
      <input type="text">
    <h3>What is this?</h3>
    <p>Experimenting with different transition speeds and methods for toggling in JSON configuration mode for a form. Prototype for <a href="http://mesosphere.com">Mesosphere</a> where we have a JSON option in DC/OS to configure and launch Docker containers.</p>
    <p>Some good reading:
        <li><a href="http://valhead.com/2016/05/05/how-fast-should-your-ui-animations-be/">How fast should your UI animations be?</a></li>
        <li><a href="https://www.smashingmagazine.com/2016/08/css-animations-motion-curves/">CSS Animation with motion curves</a></li>
        <li><a href="https://blog.alexmaccaw.com/css-transitions">All you need to know about CSS transitions</a></li>
        <li><a href="http://cubic-bezier.com/#.17,.67,.83,.67">Cubic Bezier tool</a></li>

  <div class="json">
    Hi I'm JSON mode

              // Transitions
  linear 500ms,
  linear 200ms,
  ease 300ms,
  ease-in 300ms,
  ease-out 300ms,
  cubic-bezier(.05, .69, .14, 1) 500ms;

@for $i from 1 through length($transitions) {
  .transition-#{$i} {
    transition: nth($transitions, $i);

// Other variables
$header: 20px;
$json-width: 50%;
$padding: 20px;

// JSON mode styles
.json {
  background: #252b3a;
  box-sizing: border-box;
  color: #fff;
  flex: 0 0 $json-width;
  font-family: monospace;
  font-size: 120%;
  margin-right: -$json-width;
  padding: $padding;
  transition-property: all;

.json--on {
  margin-right: 0;

// Form styles
.form {
  flex: 1;
  overflow: scroll;
  padding: $padding;
  .fieldset {
    clear: both;
    margin: 0 0 $padding*2;
  .fieldset__options label {
    margin-right: 10px;
    input {
      width: auto;
  label {
    display: block;
    font-size: .8em;
    margin-bottom: $padding/2;
    text-transform: uppercase;
  input {
    background: #f2f2f2;
    border: 2px solid transparent;
    border-radius: 5px;
    box-sizing: border-box;
    padding: $padding/2;
    width: 100%;
    &:focus {
      border: 2px solid #9351e5;
      outline: none;

// General styles
body {
  color: #333;
  font-family: -apple-system, "Helvetica Neue";
  height: 100%;
  line-height: 1.4;

h3 {
  margin-bottom: 0;

ol {
  color: #555;
  font-size: 14px;

code {
  background-color: #f9f2f4;
  border-radius: 4px;
  color: #c7254e;
  font-size: 90%;
  padding: 2px 4px;

header {
  background: #f9f9f9;
  border-bottom: 1px solid #eaebed;
  height: $header;
  position: fixed;
  padding: $padding;
  text-align: right;
  width: 100%;

main {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
  padding-top: 60px;

// Toggle styles
.toggle {
  margin-left: -999px;
  visibility: hidden;

.toggle + label {
  border-radius: 60px;
  cursor: pointer;
  float: left;
  font-size: 12px;
  height: 10px;
  outline: none;
  padding: 6px;
  position: relative;
  text-indent: 40px;
  user-select: none;
.toggle + label:before,
.toggle + label:after {
  content: "";
  bottom: 1px;
  display: block;
  left: 1px;
  position: absolute;
  top: 1px;
  width: 40px;
.toggle + label:before {
  background-color: #f1f1f1;
  border: 1px solid #eaebed;
  border-radius: 60px;
  right: 1px;
  transition: background 0.4s;
.toggle + label:after {
  background-color: #fff;
  border-radius: 100%;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
  transition: margin 0.4s;
  width: 20px;
.toggle:checked + label:before {
  background-color: #8ce196;
.toggle:checked + label:after {
  margin-left: 20px;

              $('.toggle').on('click', function(e) {
  $('.json').removeClass (function (index, css) {
    return (css.match (/(^|\s)transition-\S+/g) || []).join(' ');
  var transition = $("input[name='transition']:checked").val();
  if (transition == "custom") {
    var customTransition = $("input[name='custom-transition']").val();
    $('.json').attr('style','transition: ' + customTransition);
  } else {


🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.