Skip to content

Slider - Frameworks

Sliders are best suited for cases where people need to quickly set a value within a designated range. They offer an intuitive way to adjust settings like volume, price filters, or relative distances.

See also Range slider.

AndroidreleasedElementsreleasediOSreleasedReactreleasedReact 19releasedVuereleased

Elements

Usage notes

The Slider component consists of two custom elements that work together:

  • <w-slider> - A container that creates a <fieldset> and coordinates shared state and attributes.
  • <w-slider-thumb> - The <input type="range">, tooltip and text field.

Example

html
<form id="audio">
  <w-slider label="Volume" min="0" max="100">
    <w-slider-thumb name="volume"></w-slider-thumb>
  </w-slider>
</form>
<script>
  document.forms["audio"].addEventListener("input", function () {
    const formData = new FormData(this);
    const value = formData.get("volume");
  });
</script>

Props - w-slider

Optional attributes

These attributes can be set in HTML or as attribute expressions in Lit.

NameTypeDefaultDescription
labelstringNB: You must either use this prop or the label slot (<legend slot="label">Production year</legend>).
minnumber0The minimum allowed value in the range inputs.
maxnumber100The maximum allowed value in the range inputs.
suffixstringShows a suffix in the tooltip and text inputs.
help-textstringAdditional description to show below the fieldset.
invalidbooleanfalseSets the form fields and fieldset in an invalid state.
requiredbooleanfalseWhether a value is required or not. In practice a range input will always produce a value.
errorstringValidation error text, if any.
open-endedbooleanfalseWhether the slider's text field allow values outside the minimum and maximum of the range input.
stepnumberSets step on the range input to jump between values when dragging.
hidden-textfieldbooleanfalseSee usage notes about exceptions.
disabledbooleanfalseSee usage notes about disabled form fields.

Optional properties

These properties can be set using JavaScript or property expressions in Lit.

NameTypeDefaultDescription
valueFormatter(value: string, slot: SliderSlot) => string;Function that lets you format the output in tooltips and the textfields.
labelFormatter(slot: SliderSlot) => string;Function that lets you format the range labels.

Props - w-slider-thumb

Required attributes

These attributes can be set in HTML or as attribute expressions in Lit.

NameTypeDescription
namestringThe name of this input field in the form. The canonical source of the value is the text field.

Optional attributes

These attributes can be set in HTML or as attribute expressions in Lit.

NameTypeDefaultDescription
aria-labelstringThe label attribute from w-slider.Label for the range input.
aria-descriptionstringContextual information for assistive technology, should it be needed.
valuestringThe initial value, if any.
placeholderstringPlaceholder in empty text fields.