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

              
                <div class="slider-container">
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
    <path d="M13.7 2.30021C12.7 1.80021 11.6 2.00021 10.7 2.70021C8.6 4.40021 6.3 6.00021 3.8 7.30021C2.1 8.20021 1 10.0002 1 12.0002C1 13.9002 2.1 15.7002 3.8 16.7002C6.1 17.9002 8.4 19.5002 10.7 21.4002C11.2 21.8002 11.8 22.0002 12.5 22.0002C12.9 22.0002 13.3 21.9002 13.7 21.7002C14.7 21.2002 15.3 20.3002 15.3 19.2002V4.80021C15.3 3.70021 14.7 2.70021 13.7 2.30021Z" fill="currentColor" />
    <path d="M17.3 14.8002C17.5 15.0002 17.8 15.1002 18 15.1002C18.2 15.1002 18.5 15.0002 18.7 14.8002C19.5 14.1002 19.9 13.0002 19.9 11.9002C19.9 10.8002 19.5 9.8002 18.7 9.0002C18.3 8.6002 17.7 8.6002 17.3 9.0002C16.9 9.4002 16.9 10.0002 17.3 10.4002C17.7 10.8002 17.9 11.3002 17.9 11.8002C17.9 12.3002 17.7 12.8002 17.3 13.2002C16.9 13.8002 16.9 14.4002 17.3 14.8002Z" fill="currentColor" />
    <path d="M18.5001 5.10008C18.0001 4.90008 17.4001 5.10008 17.2001 5.60008C17.0001 6.10008 17.2001 6.70008 17.7001 6.90008C19.7001 7.80008 21.0001 9.80008 21.0001 11.9001C21.0001 14.1001 19.7001 16.1001 17.6001 17.0001C17.1001 17.2001 16.9001 17.8001 17.1001 18.3001C17.3001 18.7001 17.6001 18.9001 18.0001 18.9001C18.1001 18.9001 18.3001 18.9001 18.4001 18.8001C21.2001 17.7001 23.0001 15.0001 23.0001 12.0001C23.0001 9.00008 21.2001 6.30008 18.5001 5.10008Z" fill="currentColor" />
  </svg>
  <input id="slider" type="range" min="0" max="1000" value="1000">

</div>
              
            
!

CSS

              
                :root {
  --fill-bar-width: var(--slider-max-width);
  --slider-max-width: 150px;
}

body {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  min-height: 400px;
  background-color: #faf9fd;

  .slider-container {
    display: flex;
    align-items: center;
    transform: rotateZ(-90deg);

    input[type="range"] {
      position: relative;
      -webkit-appearance: none;
      z-index: 1;
      width: var(--slider-max-width);
      height: 6px;
      background: #ebeaf8;
      outline: none;
      border-radius: 6px;
      transition: 250ms;

      &:hover {
        cursor: grab;
      }

      &:active {
        cursor: grabbing;
      }

      &::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        z-index: -1;
        width: var(--fill-bar-width);
        height: 6px;
        color: #ffffff00;
        background: #4832ff;
        border-radius: 6px;
      }

      &::-webkit-slider-thumb {
        position: relative;
        -webkit-appearance: none;
        appearance: none;
        width: 14px;
        height: 14px;
        background: #4832ff;
        border-radius: 50%;
        box-shadow: -4px 0 0 -1px #17161e22;
        z-index: 2;
        transition: 100ms;

        &:hover {
          width: 18px;
          height: 18px;
        }

      }

      &::-moz-range-thumb {
        appearance: none;
        width: 12px;
        height: 12px;
        background: #4832ff;
        border-radius: 50%;
      }
    }

    svg {
      margin-right: 20px;
      transform: rotateZ(90deg);
      color: #4832ff;
    }
  }
}
              
            
!

JS

              
                const body = document.body
const root = document.querySelector(':root');
const slider = document.querySelector('#slider')

let maxValue = slider.max
let minValue = slider.min
let maxWidth = parseInt(getComputedStyle(root).getPropertyValue('--slider-max-width').slice(0, -2))
let isFalling = false
let width
const smallg = 9.8

function setWidth() {
  width = maxWidth * (slider.value - minValue) / (maxValue - minValue)
  root.style.setProperty('--fill-bar-width', `${width}px`)
}

window.onload = init()

function init() {
  setWidth()
  falling() // If you want a normal range slider, just remove this
}

slider.addEventListener('input', setWidth)

// If you want a normal range slider, just remove this
slider.addEventListener('change', () => {
  if (!isFalling) {
    falling()
  }
})

// If you want a normal range slider, just remove this
function falling() {
  isFalling = true
  let velocity = 0
  let precision = 64
  let speed = 16
  let restitution = 0.5
  let isbounced = false
  let fall = setInterval(() => {
    if (slider.value > minValue && isbounced === false) {
      velocity += smallg / (precision / speed)
      slider.value -= velocity
      setWidth()
    } else {
      isbounced = true
      if (velocity > 0) {
        velocity -= smallg / (precision / speed)
        slider.value = +slider.value + velocity * restitution
        setWidth()
      } else if (slider.value > minValue) {
        clearInterval(fall);
        falling()
      } else {
        clearInterval(fall);
        isFalling = false
      }
    }
  }, 1000 / precision)
}
              
            
!
999px

Console