Pre-Release — API subject to change

Sliders & Dials

Part of the ProControls for p5.js documentation.

New here? See the Getting Started page for HTML setup, script tags, a minimal sketch, and the common options table.

AnalogSlider MultiSlider RangeSlider Dial MultiDial

AnalogSlider Input

A vertical fader with a draggable cap, optional scale ticks, and a live readout. Drag the cap or scroll the mouse wheel to change value. Double-click the cap to reset to the initial value.

new AnalogSlider(opts)

Options

OptionTypeDefaultDescription
horizontalbooleanfalseWhen true, the fader runs left-to-right instead of bottom-to-top. Default width becomes 180 and default height becomes 44. showScale defaults to false in horizontal mode.
widthnumberauto / 180Panel width. Vertical: auto-sized to fit tick labels when showScale is true. Horizontal: defaults to 180.
heightnumber180 / 44Panel height. Vertical default 180, horizontal default 44.
readoutstring'raw''raw' — numeric value · 'percent' — 0–100% · 'db' — dB relative to max (shows -∞ at min).
decimalsnumber2Decimal places for the 'raw' readout.
showScalebooleantrue / falseDraw tick marks and numeric labels along the track. Defaults true vertical, false horizontal.
stylestring'knob'Visual style — 'knob' (default), 'wheel' (cylinder with scrolling ribs), 'button' (minimal circular cap). Works for both vertical and horizontal orientations. See slider styles below.
showFaderbooleantrueShow or hide the draggable cap. false = display-only meter.
springBackbooleanfalseWhen true, the fader animates back to its initial value after mouse/touch release.
springDurationnumber1.0Seconds for the spring animation to complete.
springDefaultnumbervalueValue to restore on double-click reset (and spring-back target). Defaults to the initial value. Override when the control is rebuilt dynamically to pin the reset point.
onChangefunctionnullonChange(value[, control]) — called every time the value changes during interaction.
onReleasefunctionnullonRelease(value[, control]) — called on mouse/touch release.

Example

editable — changes update the preview
Log scale: Set scale: 'log' with a small positive min (e.g. 0.001) for a perceptually even frequency fader.

Slider styles

Set style on any vertical AnalogSlider to change its visual. Interaction is identical across all styles.

knob (default)
wheel
button

wheel — a cylinder visible through a slot. Ribs scroll with the value position; center notches mark the midpoint. Vertical: horizontal ribs, width defaults to 50px. Horizontal: vertical ribs, full slot is draggable. Scale defaults to off.

button — a minimal thin-groove track with a spherical circular cap. Works in both orientations. Width defaults to 40px and scale defaults to off.


MultiSlider Input

Several AnalogSlider faders arranged side-by-side in a single unit — useful for equalizers, mixer channel strips, or any bank of related faders. A single onChange/onRelease fires whenever any child slider changes, receiving a name → value object covering all sliders at once.

new MultiSlider(opts)

Options

OptionTypeDefaultDescription
slidersobject{}Each key is a slider name/label. The value is either a number (initial value) or an object with per-slider overrides (value, min, max, readout, …).
xnumber20Left edge of the first slider.
ynumber20Top edge of all sliders.
heightnumber180Slider height in pixels (shared by all children unless overridden per-slider).
minnumber0Shared minimum (overridable per-slider).
maxnumber1Shared maximum (overridable per-slider).
readoutstring'raw'Shared readout format — 'raw', 'db', or 'pct' (overridable per-slider).
decimalsnumber2Shared decimal places (overridable per-slider).
scalestring'linear'Shared scale — 'linear' or 'log' (overridable per-slider).
horizontalbooleanfalseWhen true, each child is a horizontal slider and the group stacks them vertically. Default width becomes 180 and default height becomes 44 per slider.
gapnumber4Pixel gap between adjacent sliders.
labelstring''Group label (not drawn — available for identification).
namestringautoIdentifier for this group. Each child slider also has its own name (defaults to its key with spaces/punctuation removed), which becomes the field key in .values and .slider(name). Override a child's name via its per-slider object: sliders: { freq: { name: 'f', … } }.
onChangefunctionnullonChange({ name: value, … }[, control]) — called when any slider changes. Keys are each child slider's .name (label with spaces/punctuation removed by default).
onReleasefunctionnullonRelease({ name: value, … }[, control]) — called on mouse/touch release.
stylestring'knob'Shared slider style — 'knob', 'wheel', or 'button'. Can be overridden per-slider.
springBackbooleanfalseWhen true, all sliders animate back to their initial values after release. Can be overridden per-slider.
springDurationnumber1.0Seconds for the spring animation to complete. Can be overridden per-slider.
themeobject{}Shared theme override applied to all children. See Themes.

Properties & methods

Property / methodDescription
.valuesGetter — returns { name: value, … } for all sliders. Keys are each child's .name property (label with spaces/punctuation removed by default; override via name in the per-slider opts). Setter accepts the same format to update any subset.
.slider(name)Returns the child AnalogSlider whose .name matches, for direct access (e.g. .value, .disabled).
.disabledGetter/setter — propagates to all child sliders.

Per-slider overrides

Pass an object instead of a plain number for any slider to override shared options for that specific channel.

const eq = new MultiSlider({
  x: 20, y: 40, height: 180,
  min: -12, max: 12, readout: 'raw', decimals: 1,
  sliders: {
    '60Hz':  0,           // plain number → uses shared min/max
    '250Hz': 0,
    '2kHz':  { value: 3, theme: { capIndicator: '#ff6600' } }, // object → per-slider overrides
    '8kHz':  0,
  },
  onChange:  v => console.log('eq changed', v),
  onRelease: v => console.log('eq released', v),
});

Example — vertical (default)

editable — changes update the preview

Example — horizontal with a spring-back override on one slider

editable — changes update the preview

RangeSlider Input

A fader with two draggable caps that define a low/high range. Drag either cap independently; caps constrain each other so they never cross. The region between the caps is filled with the accent colour. Scroll-wheel adjusts the cap nearest the cursor. Double-click a cap to reset it to its initial value.

new RangeSlider(opts)

Options

OptionTypeDefaultDescription
x, ynumber20, 20Top-left position.
widthnumber50 (v) / 180 (h)Panel width in pixels.
heightnumber180 (v) / 44 (h)Panel height in pixels.
minnumber0Minimum value.
maxnumber1Maximum value.
valueLownumberminInitial lower handle value.
valueHighnumbermaxInitial upper handle value.
horizontalbooleanfalseWhen true, renders as a horizontal slider. Width/height defaults swap accordingly.
readoutstring'raw'Value format — 'raw', 'percent', or 'db'.
decimalsnumber2Decimal places for 'raw' readout.
showScalebooleantrue (v) / false (h)Draw tick marks and value labels alongside the track.
showFaderbooleantrueDraw the cap handles. Set to false to show only the range fill (display-only mode).
labelstring''Caption drawn at the top of the panel.
onChangefunctionnullonChange({lo, hi}[, control]) — called whenever either handle moves.
onReleasefunctionnullonRelease({lo, hi}[, control]) — called on mouse/touch release.
disabledbooleanfalseDisables interaction and renders a translucent overlay.
themeobject{}Partial theme override. See Themes.

Properties

PropertyDescription
.valueLowCurrent lower value (read/write). Setting it programmatically will not fire onChange.
.valueHighCurrent upper value (read/write).

Example — vertical

editable — changes update the preview

Example — horizontal

editable — changes update the preview

Dial Input

A rotary knob with a 270° arc sweep. Drag up/down or scroll the mouse wheel to turn it. A tooltip shows the live value while dragging. Double-click to reset to the initial value.

new Dial(opts)

Options

OptionTypeDefaultDescription
sizenumber70Square panel size in pixels. Knob, arc, and scale all scale proportionally.
readoutstring'raw'Same as AnalogSlider: 'raw', 'percent', 'db'.
decimalsnumber2Decimal places for the 'raw' readout.
showScalebooleanfalseDraw tick marks and labels around the arc. Increase size if labels clip.
showKnobbooleantrueShow or hide the knob body. false = arc-only display (used by VUDial).
stylestring'classic'Knob visual style — 'classic' · 'rubber' · 'grooved' · 'pointer'. See dial styles below.
springBackbooleanfalseWhen true, the knob animates back to its initial value after mouse/touch release.
springDurationnumber1.0Seconds for the spring animation to complete.
onChangefunctionnullonChange(value[, control]) — called every time the value changes.
onReleasefunctionnullonRelease(value[, control]) — called on mouse/touch release.

Example

editable — changes update the preview

Dial styles

Set style to choose a knob visual. All styles share the same interaction and arc track — only the knob body rendering changes.

classic (default)
rubber
grooved
pointer

MultiDial Input

Several Dial knobs arranged side-by-side in a single unit. A single onChange/onRelease fires whenever any dial changes, receiving a name → value object. A raised bevel panel frames the group. All dials share options by default; individual dials can override with per-dial objects.

new MultiDial(opts)

Options

OptionTypeDefaultDescription
dialsobject{}Each key is a dial name/label. Value is a number (initial value) or an object with per-dial overrides (value, min, max, style, …).
xnumber20Left edge of the first dial.
ynumber20Top edge of all dials.
sizenumber70Shared dial panel size in pixels (overridable per-dial).
minnumber0Shared minimum (overridable per-dial).
maxnumber1Shared maximum (overridable per-dial).
readoutstring'raw'Shared readout format (overridable per-dial).
decimalsnumber2Shared decimal places (overridable per-dial).
horizontalbooleantrueWhen true (default), dials are arranged in a horizontal row. When false, dials are stacked in a vertical column.
stylestring'classic'Shared knob style — 'classic', 'rubber', 'grooved', 'pointer' (overridable per-dial).
gapnumber4Pixel gap between adjacent dials.
namestringautoIdentifier for this group. Each child dial also has its own name (defaults to its key with spaces/punctuation removed), which becomes the field key in .values and .dial(name). Override a child's name via its per-dial object: dials: { freq: { name: 'f', … } }.
onChangefunctionnullonChange({ name: value, … }[, control]) — called when any dial changes. Keys are each child dial's .name property (label with spaces/punctuation removed by default).
onReleasefunctionnullonRelease({ name: value, … }[, control]) — called on mouse/touch release.
springBackbooleanfalseWhen true, all dials animate back to their initial values after release. Can be overridden per-dial.
springDurationnumber1.0Seconds for the spring animation to complete. Can be overridden per-dial.
themeobject{}Shared theme override. See Themes.

Properties & methods

Property / methodDescription
.valuesGetter — returns { name: value, … } for all dials. Keys are each child's .name property (label with spaces/punctuation removed by default; override via name in the per-dial opts). Setter accepts same format.
.dial(name)Returns the child Dial whose .name matches, for direct access.
.disabledGetter/setter — propagates to all child dials.

Example — horizontal row (default)

editable — changes update the preview

Example — vertical column with an individual dial override

editable — changes update the preview