<nd-slider>

Several improvements over the native <input type=range>.

Features

Examples

Basic

Simplest version:

<nd-slider></nd-slider>

You can also provide a specific slider element yourself so it can be easier to style or customize:

<nd-slider>
	<input type=range>
</nd-slider>

You can also provide a specific element for the value:

<nd-slider>
	<sl-format-number slot="value" type="currency" currency="USD"></sl-format-number>
</nd-slider>

If it has a value property it will be assumed to be editable, otherwise it will be read-only.


All usual slider attributes work and are simply copied to the slider and spinner elements:

<nd-slider min="-180" max="180" step="0.01"></nd-slider>

You are encouraged to provide a slider with the right attributes from the start, to minimize updates.


By default the number is shown as a read/write tooltip, but you can make it display inline:

<nd-slider style="--value-position: end"></nd-slider>

Yes, this is a regular CSS property that you can even set in your stylesheet. It requires style queries, which means at the time of this writing, it won’t work in Firefox.

By default shown is the slider value, but you can switch to showing (and editing) the progress instead:

<nd-slider show="progress"></nd-slider>

Properties and methods

In addition to the usual properties and methods of a slider (min, max, step, value, defaultValue), the following are available:

Installation

Just include the component’s JS file and you’re good:

<script src="https://nudeui.com/elements/nd-slider/nd-slider.js" type="module"></script>

In case you want to link to local files: CSS is fetched automatically, and assumed to be in the same directory as the JS file.