Pen Settings



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


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


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.


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.


  <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="">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="">How fast should your UI animations be?</a></li>
        <li><a href="">CSS Animation with motion curves</a></li>
        <li><a href="">All you need to know about CSS transitions</a></li>
        <li><a href=",.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 {