Skip to content

Range Slider (noUiSlider) Element ​

The Range Slider element allows users to select a single value or a range of values by sliding handles along a track. It's highly customizable and suitable for selecting numeric ranges, like price, age, or percentages.

In BetterForms, this element leverages the noUiSlider library to provide a touch-friendly and flexible range selection interface.

Common Configuration Properties ​

PropertyTypeDescription
typeStringMust be set to "noUiSlider".
labelStringThe label for the range slider.
modelStringThe key in your BetterForms data model where the selected value or array of values (for range) will be stored.
disabledBooleanIf true, the slider will be visible but not interactive. Defaults to false.
readonlyBooleanIf true, the slider value cannot be changed. Similar to disabled. Defaults to false.
hintStringAdditional helper text displayed below the slider.
styleClassesString / ArrayCSS classes for styling the wrapper.
fieldOptionsObjectCrucial property. Options passed directly into window.noUiSlider.create(...).

fieldOptions common settings: ​

OptionTypeDescription
startNumber / ArrayInitial value(s) of the slider. A single number for one handle, an array of two numbers for a range (e.g., [20, 80]).
rangeObjectDefines the slider's min and max values. E.g., { 'min': 0, 'max': 100 }.
connectBoolean / Array / StringHighlights the area between handles or from an edge to a handle. true for a range, [true, false] for lower connect.
stepNumberThe increment/decrement step size.
orientationStringOrientation of the slider: "horizontal" (default) or "vertical".
tooltipsBoolean / Array / ObjectWhether to show tooltips above the handles. Can be true, or an array of formatter objects.
formatObjectAn object with to and from functions for formatting the displayed values (e.g., adding units like '$' or '%').
behaviourStringUser interaction behavior, e.g., 'tap-drag', 'drag'.
pipsObjectConfiguration for displaying pips (markers) along the slider.

Example Schema Snippet (Single Value Slider) ​

json
{
  "type": "noUiSlider",
  "label": "Set Volume",
  "model": "volumeLevel",
  "fieldOptions": {
    "min": 0,
    "max": 100,
    "step": 1,
    "tooltips": true,
    "connect": [true, false]
  }
}

Example Schema Snippet (Range Slider) ​

json
{
  "type": "noUiSlider",
  "label": "Price Range",
  "model": "priceRangeArray",
  "fieldOptions": {
    "min": 0,
    "max": 1000,
    "double": true,
    "step": 10,
    "connect": true,
    "tooltips": true,
    "format": {
      "to": function (value) { return '$' + parseInt(value); },
      "from": function (value) { return Number(value.replace('$', '')); }
    }
  }
}

Klai Studio Specific Notes ​

  • The component requires the noUiSlider library to be loaded globally.
  • The model stores a single number for one handle, or a two-item number array for a range.
  • If the model already has a value, that value is used as the slider start.
  • If there is no current model value, the component builds start from fieldOptions.min, and uses [min, min] when fieldOptions.double is present.
  • fieldOptions.pips and fieldOptions.tooltips also affect wrapper classes used for spacing.

Full Property Reference ​

This element wraps the noUiSlider library. For the available fieldOptions, refer to:

Klai Studio documentation