Dogfalo/materialize · error · Error

noUiSlider: 'limit' option is only supported on linear slide

Error message

noUiSlider: 'limit' option is only supported on linear sliders with 2 or more handles.

What it means

Thrown by testLimit when getMargin returns false (non-linear range) OR parsed.handles < 2. limit only constrains the maximum gap between handles, so it requires at least two handles AND a linear range; failing either condition triggers this combined message.

Source

Thrown at extras/noUiSlider/nouislider.js:620

        }

        parsed.margin = parsed.spectrum.getMargin(entry);

        if ( !parsed.margin ) {
            throw new Error("noUiSlider: 'margin' option is only supported on linear sliders.");
        }
    }

    function testLimit ( parsed, entry ) {

        if ( !isNumeric(entry) ){
            throw new Error("noUiSlider: 'limit' option must be numeric.");
        }

        parsed.limit = parsed.spectrum.getMargin(entry);

        if ( !parsed.limit || parsed.handles < 2 ) {
            throw new Error("noUiSlider: 'limit' option is only supported on linear sliders with 2 or more handles.");
        }
    }

    function testPadding ( parsed, entry ) {

        if ( !isNumeric(entry) ){
            throw new Error("noUiSlider: 'padding' option must be numeric.");
        }

        if ( entry === 0 ) {
            return;
        }

        parsed.padding = parsed.spectrum.getMargin(entry);

        if ( !parsed.padding ) {
            throw new Error("noUiSlider: 'padding' option is only supported on linear sliders.");
        }

View on GitHub (pinned to 824e78248b)

Solutions

  1. Ensure at least two start values and a linear range.
  2. Remove limit for single-handle sliders.
  3. Remove intermediate stops from range so getMargin returns a real value.

Example fix

// before
start: [50], limit: 20
// after
start: [50]   // limit removed
Defensive patterns

Strategy: validation

Validate before calling

const handles = (Array.isArray(opts.start) ? opts.start : [opts.start]).length;
function isLinearRange(range) { return Object.keys(range).length === 2 && 'min' in range && 'max' in range; }
if (opts.limit != null && (handles < 2 || !isLinearRange(opts.range))) {
  throw new Error('limit requires >= 2 handles and a linear range');
}

Try / catch

try { noUiSlider.create(el, opts); }
catch (e) { if (/limit' option is only supported/.test(e.message)) { delete opts.limit; /* retry */ } else throw e; }

Prevention

When it happens

Trigger: Single handle: start: [50], limit: 20. Non-linear range: range: { min: 0, '50%': 50, max: 100 }, start: [10, 90], limit: 40.

Common situations: Setting limit on a one-handle slider, or switching the range to a stepped scale while leaving limit in place.

Related errors


AI-assisted analysis of Dogfalo/materialize@824e78248b (2026-08-13). Data as JSON: /api/errors/c2efb3604c5500d8. Report an issue: GitHub.