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="wrapper js-wrapper">
  <div class="content">
    <ul>
      <li class="relative">
        <div class="item">
          <figure class="icon-wrapper">
            <canvas class="icon js-riv-canvas" role="img" aria-label="Lock icon" width="24" height="24"></canvas>
          </figure>
          
          <label class="label" for="switch-checkbox-1">Share Session</label>
          
          <label class="switch" for="switch-checkbox-1">
            <input class="sr-only" type="checkbox" id="switch-checkbox-1" data-checkbox="0">
            <div class="switch-marker" aria-hidden="true"></div>
          </label>
        </div>
        
        <div class="divider" aria-hidden="true"></div>
      </li>
      
      <li class="relative">
        <div class="item">
          <figure class="icon-wrapper">
            <canvas class="icon js-riv-canvas" role="img" aria-label="Password icon" width="24" height="24"></canvas>
          </figure>
          
          <label class="label" for="switch-checkbox-2">Request Passcode</label>
          
          <label class="switch" for="switch-checkbox-2">
            <input class="sr-only" type="checkbox" id="switch-checkbox-2" data-checkbox="1">
            <div class="switch-marker" aria-hidden="true"></div>
          </label>
        </div>
        
        <div class="divider" aria-hidden="true"></div>
      </li>
      
      <li class="relative">
        <div class="item">
          <figure class="icon-wrapper">
            <canvas class="icon js-riv-canvas" role="img" aria-label="Envelope icon" width="24" height="24"></canvas>
          </figure>
          
          <label class="label" for="switch-checkbox-3">Request Guest Email</label>
          
          <label class="switch" for="switch-checkbox-3">
            <input class="sr-only" type="checkbox" id="switch-checkbox-3" data-checkbox="2">
            <div class="switch-marker" aria-hidden="true"></div>
          </label>
        </div>
      </li>
    </ul>
  </div>
</div>
              
            
!

CSS

              
                body {
  background-color: #D4D5D3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: Inter, sans-serif;
}

.wrapper {
  width: 330px;
  background-color: #E8E9E8;
  border-radius: 12px;
  padding: 3px;
  box-shadow: 69px 191px 81px rgba(0, 0, 0, 0.01), 39px 107px 69px rgba(0, 0, 0, 0.04), 17px 48px 51px rgba(0, 0, 0, 0.07), 4px 12px 28px rgba(0, 0, 0, 0.08), inset 0px 0px 1px 1px rgba(255, 255, 255, 0.25);
}

.content {
  width: 100%;
  height: 100%;
  background: rgba(250, 250, 250, 0.9);
  box-shadow: 0px 7px 4px rgba(11, 3, 45, 0.01), 0px 3px 3px rgba(11, 3, 45, 0.02), 0px 1px 2px rgba(11, 3, 45, 0.03);
  border-radius: 9px;
}

.item {
  height: 80px;
  display: flex;
  align-items: center;
  padding: 20px;
}

.item::before { /* left gradient line */
  content: '';
  height: 60px;
  width: 1px;
  position: absolute;
  left: -1px;
  background: linear-gradient(hsla(358, 100%, 68%, 0%), hsla(358, 100%, 68%, 40%), hsla(358, 100%, 68%, 0%));
  opacity: 0;
  transition: opacity .2s;
}

.icon-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background-color: hsla(40, 7%, 8%, 5%);
  border: 1px solid transparent;
  border-radius: 6px;
  margin-right: 16px;
  transition: .2s;
}

.icon-wrapper::after { /* gradient border */
  content: '';
  position: absolute;
  inset: -1px;
  border: inherit;
  border-radius: inherit;
  background: linear-gradient(hsla(358, 100%, 68%, 50%), hsla(358, 100%, 68%, 66%)) border-box;
  mask: linear-gradient(black, black) padding-box, linear-gradient(black, black);
  mask-composite: exclude;
  opacity: 0;
  transition: opacity .2s;
}

.icon {
  height: 24px;
  width: 24px;
}

.label {
  font-size: 14px;
  font-weight: 600;
  color: #171614;
  flex-grow: 1;
  
  background: linear-gradient(to right, #9F524F, #171614 40px);
  color: transparent;
  background-clip: text;
  background-position: -40px 0;
  transition: background-position .2s;
}

.switch {
  width: 34px;
  height: 20px;
  background: #D2D2D0;
  box-shadow: 0px 1px 1px rgba(255, 255, 255, 0.94), inset 0px 1px 2px rgba(23, 22, 20, 0.13);
  border-radius: 50em;
  margin-left: auto;
  padding: 4px;
  transition: .2s;
}

.switch-marker {
  height: 12px;
  width: 12px;
  background: #F3F3F3;
  box-shadow: 0px 6px 2px rgba(0, 0, 0, 0.02), 0px 3px 2px rgba(0, 0, 0, 0.06), 0px 2px 2px rgba(0, 0, 0, 0.09), 0px 0px 1px rgba(0, 0, 0, 0.11), inset 0px 1px 0px #FFFFFF;
  border-radius: 50%;
  transition: transform .2s;
}

.switch:has(input:checked) {
  background: #FF5A5F;
  box-shadow: 0px 1px 1px rgba(255, 255, 255, 0.2), inset 0px 1px 2px rgba(23, 22, 20, 0.28);
}

.switch:has(input:checked) .switch-marker {
  transform: translateX(14px);
}

.divider {
  position: absolute;
  left: 20px;
  bottom: 0;
  background-color: hsla(40, 7%, 8%, 6%);
  height: 1px;
  width: calc(100% - 40px);
}

.divider::after {
  content: '';
  position: absolute;
  top: 1px;
  height: 1px;
  left: 0;
  width: 100%;
  background-color: white;
}

.item:has(input:checked)::before {
  opacity: 1;
}

.item:has(input:checked) .icon-wrapper {
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0px 2px 4px rgba(255, 90, 95, 0.3), 0px 0px 0px 2px rgba(255, 90, 95, 0.13), inset 0px -2.5px 0px rgba(255, 90, 95, 0.25);
}

.item:has(input:checked) .icon-wrapper::after { /* make border gradient visible */
  opacity: 1;
}

.item:has(input:checked) .label {
  background-position: 0 0;
}
              
            
!

JS

              
                let rivCanvas = document.getElementsByClassName('js-riv-canvas');

const r1 = new rive.Rive({
  src: 'https://anim-icons.s3.amazonaws.com/lock.riv',
  canvas: rivCanvas[0],
  autoplay: false,
  stateMachines: 'lockAnimation',
  onLoad: () => {
    r1.resizeDrawingSurfaceToCanvas();
    triggerAnim(document.getElementById('switch-checkbox-1'), r1, 'lockAnimation');
  }
});

const r2 = new rive.Rive({
  src: 'https://anim-icons.s3.amazonaws.com/password.riv',
  canvas: rivCanvas[1],
  autoplay: false,
  stateMachines: 'passwordAnimation',
  onLoad: () => {
    r2.resizeDrawingSurfaceToCanvas();
    triggerAnim(document.getElementById('switch-checkbox-2'), r2, 'passwordAnimation');
  }
});

const r3 = new rive.Rive({
  src: 'https://anim-icons.s3.amazonaws.com/envelope.riv',
  canvas: rivCanvas[2],
  autoplay: false,
  stateMachines: 'envelopeAnimation',
  onLoad: () => {
    r3.resizeDrawingSurfaceToCanvas();
    triggerAnim(document.getElementById('switch-checkbox-3'), r3, 'envelopeAnimation');
  }
});

function triggerAnim(trigger, rivObj, stateMachine) {
  const inputs = rivObj.stateMachineInputs(stateMachine);
  let isActive = inputs.find(i => i.name === 'isActive');
  trigger.addEventListener('change', function(event) {
    isActive.value = event.target.checked;
    rivObj.pause();
    isActive.value ? rivObj.play('active') : rivObj.play('inactive');
  });
}
              
            
!
999px

Console