Float

By passing the float prop to the component, we can have a nice label which floats above the handle and shows the current value.

Hover/Drag the Slider handles below to see the float

<RangeSlider float />
Floating Labels
25 75
25,75

Float without Hover

The Slider can be initialised with hoverable set false which will prevent the float from appearing on hover.

<RangeSlider float />
<RangeSlider float hoverable={false} />
Floating Labels

Regular (with Hover)

25 75

No Hover

25 75
25,75

Always show the floats

We can set the floats to always be visible by modifying the css slightly.

<RangeSlider id="always" float range bind:values />

<style>
  :global(#always .rangeFloat) {
    opacity: 1;
  }
</style>
Always Shown Floats
25 75

Focus on load

It’s possible to focus the slider on load with a little bit of javascript.

<script>
  let slider;

  $: if ( slider ) {
    slider.querySelector('.rangeHandle').focus();
  }
</script>

<RangeSlider bind:slider float />
Focus on load
50

(refresh the page to see the focus effect in action)