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="h-screen flex justify-center items-center">
  <div x-data="range()" x-init="mintrigger(); maxtrigger()" class="relative max-w-xl w-full">
    <div>
      <input type="range" step="100" x-bind:min="min" x-bind:max="max" x-on:input="mintrigger" x-model="minprice" class="absolute pointer-events-none appearance-none z-20 h-2 w-full opacity-0 cursor-pointer">

      <input type="range" step="100" x-bind:min="min" x-bind:max="max" x-on:input="maxtrigger" x-model="maxprice" class="absolute pointer-events-none appearance-none z-20 h-2 w-full opacity-0 cursor-pointer">

      <div class="relative z-10 h-2">

        <div class="absolute z-10 left-0 right-0 bottom-0 top-0 rounded-md bg-gray-200"></div>

        <div class="absolute z-20 top-0 bottom-0 rounded-md bg-green-300" x-bind:style="'right:'+maxthumb+'%; left:'+minthumb+'%'"></div>

        <div class="absolute z-30 w-6 h-6 top-0 left-0 bg-green-300 rounded-full -mt-2" x-bind:style="'left: '+minthumb+'%'"></div>

        <div class="absolute z-30 w-6 h-6 top-0 right-0 bg-green-300 rounded-full -mt-2" x-bind:style="'right: '+maxthumb+'%'"></div>

      </div>

    </div>

      <div class="flex items-center justify-between pt-5 space-x-4 text-sm text-gray-700">
        <div>
          <input type="text" maxlength="5" x-on:input.debounce="mintrigger" x-model="minprice"
            wire:model.debounce.300="minPrice"
            class="w-24 px-3 py-2 text-center border border-gray-200 rounded-lg bg-gray-50 focus:border-yellow-400 focus:outline-none">
        </div>
        <div>
          <input type="text" maxlength="5" x-on:input.debounce.300="maxtrigger" x-model="maxprice"
            wire:model.debounce="maxPrice"
            class="w-24 px-3 py-2 text-center border border-gray-200 rounded-lg bg-gray-50 focus:border-yellow-400 focus:outline-none">
        </div>
      </div>

  </div>

  <script>
    function range() {
      return {
        minprice: 0,
        maxprice: 10000,
        min: 0,
        max: 10000,
        minthumb: 0,
        maxthumb: 0,
        mintrigger() {
          this.validation();
          this.minprice = Math.min(this.minprice, this.maxprice - 500);
          this.minthumb = ((this.minprice - this.min) / (this.max - this.min)) * 100;
        },
        maxtrigger() {
          this.validation();
          this.maxprice = Math.max(this.maxprice, this.minprice + 200);
          this.maxthumb = 100 - (((this.maxprice - this.min) / (this.max - this.min)) * 100);
        },
        validation() {
          if (/^\d*$/.test(this.minprice)) {
            if (this.minprice > this.max) {
              this.minprice = 9500;
            }
            if (this.minprice < this.min) {
              this.minprice = this.min;
            }
          } else {
            this.minprice = 0;
          }
          if (/^\d*$/.test(this.maxprice)) {
            if (this.maxprice > this.max) {
              this.maxprice = this.max;
            }
            if (this.maxprice < this.min) {
              this.maxprice = 200;
            }
          } else {
            this.maxprice = 10000;
          }
        }
      }
    }
  </script>
  <div class="flex items-end justify-end absolute bottom-0 right-0 mb-4 mr-4">
    <div>
      <a title="Buy me a coffee" href="https://www.buymeacoffee.com/rHcLDkY" target="_blank" class="block w-16 h-16">
        <img alt="Buy me a coffee" class="object-cover object-center w-full h-full rounded-full shadow-md hover:shadow-lg" src="https://cdn.dribbble.com/users/3349322/screenshots/14039201/media/616e4ae6995fb288e434c3f0927541ce.png"/>
      </a>   
    </div>
  </div>
</div>
              
            
!

CSS

              
                input[type=range]::-webkit-slider-thumb {
	pointer-events: all;
	width: 24px;
	height: 24px;
	-webkit-appearance: none;
  
/* @apply w-6 h-6 appearance-none pointer-events-auto; */
}

              
            
!

JS

              
                // var inputLeft = document.getElementById("input-left");
// var inputRight = document.getElementById("input-right");

// var thumbLeft = document.querySelector(".slider > .thumb.left");
// var thumbRight = document.querySelector(".slider > .thumb.right");
// var range = document.querySelector(".slider > .range");

// function setLeftValue() {
// 	var _this = inputLeft,
// 		min = parseInt(_this.min),
// 		max = parseInt(_this.max);

// 	_this.value = Math.min(parseInt(_this.value), parseInt(inputRight.value) - 1);

// 	var percent = ((_this.value - min) / (max - min)) * 100;

// 	thumbLeft.style.left = percent + "%";
// 	range.style.left = percent + "%";
// } 
// setLeftValue();

// function setRightValue() {
// 	var _this = inputRight,
// 		min = parseInt(_this.min),
// 		max = parseInt(_this.max);

// 	_this.value = Math.max(parseInt(_this.value), parseInt(inputLeft.value) + 1);

// 	var percent = ((_this.value - min) / (max - min)) * 100;

// 	thumbRight.style.right = (100 - percent) + "%";
// 	range.style.right = (100 - percent) + "%";
// }
// setRightValue();

// inputLeft.addEventListener("input", setLeftValue);
// inputRight.addEventListener("input", setRightValue);

              
            
!
999px

Console