Sliders & Dials Tutorial

ProControls for p5.js — by David Stein
Step-by-step guide for beginners — all examples are live and editable
↗ Full Docs
Welcome! This tutorial walks you through every slider and dial control in ProControls, one step at a time. You do not need any prior experience with JavaScript or p5.js — each example is fully explained, and every code block on this page is live and editable. Just click inside the code, make a change, and the preview on the right will update automatically.
First time here? Before running these examples in your own project, visit the Getting Started page to get the HTML setup and script tags you need to load ProControls.
AnalogSlider Dial MultiSlider MultiDial RangeSlider

AnalogSlider

Fader

An AnalogSlider is a fader — a handle you drag up and down (or left and right) to set a value. Think of it like a volume fader on a mixing board. You can drag the handle, scroll the mouse wheel, or swipe on a touchscreen. Double-click the handle to snap it back to its starting position.

Step 1 Your first slider — no setup needed

The simplest way to create a slider is to write new AnalogSlider() with no options at all. ProControls will place it on your canvas automatically and give it sensible defaults. Try dragging the handle or scrolling over it!

editable — changes update the preview
Auto-placement: When you leave out x and y, ProControls figures out where to put the control so it does not overlap other controls on your canvas. Taller-than-wide controls are placed side by side; wider-than-tall controls stack vertically.
Step 2 Customizing your slider

Pass options inside { } curly braces to customize the slider. The most useful ones are label (the text shown on the control), min and max (the range of values), and value (where the handle starts). Try changing the numbers below!

editable — try changing min, max, value, or label
Step 3 Choosing a look with style

The style option changes how the slider looks. There are three choices: 'knob' (the default cap handle), 'wheel' (a spinning cylinder — great for pitch bend), and 'button' (a minimal round puck). Try changing 'wheel' to 'knob' or 'button' in the editor below!

editable — try 'knob', 'wheel', or 'button' for style

All three styles side by side:

'knob'
'wheel'
'button'
Step 4 Driving animated artwork with .value

The real fun begins when you read the slider's value right inside your draw() loop and use it to control something on screen. This example is a complete sketch — it has its own setup() and draw(), just like a sketch in your own project. The fader sets the base size of a circle that gently pulses on its own; drag it and the artwork responds instantly.

editable — drag the fader to resize the pulsing circle
Tip: Reading slider.value in draw() is perfect for visuals that update every frame. For one-off actions when the value changes — like logging or triggering a sound — use the onChange and onRelease callbacks shown in the MultiSlider section below.

Dial

Rotary Knob

A Dial is a rotary knob — exactly like the knobs you see on a synthesizer or guitar amp. Drag up to turn it clockwise, drag down to turn it counter-clockwise, or scroll the mouse wheel. The arc around the knob shows how far it has been turned. Double-click to reset to the starting value.

Step 1 Your first dial

Just like the slider, you can create a dial with no options. ProControls places it for you and gives it a 0–1 range by default. Drag up and down on the knob to turn it.

editable — changes update the preview
Step 2 Customizing your dial

The size option sets how big the dial is in pixels. Setting scale: 'log' makes the range feel more natural for things like frequency — instead of linear steps, the knob moves faster at low values and slower at high values, which matches how human ears perceive pitch. Try turning the knob below!

editable — try changing size, min, max, or removing scale: 'log'
Step 3 Choosing a knob style

The style option changes the look of the knob body. Try 'classic' (the default — a polished cap with a dot), 'rubber' (textured grip), 'grooved' (concentric rings), or 'pointer' (a flat disc with a thin line pointing to the value — great for panning knobs). The arc and interaction are identical for all styles.

editable — try 'classic', 'rubber', 'grooved', 'pointer'

All four dial styles:

'classic'
'rubber'
'grooved'
'pointer'
Step 4 Turning the knob to drive artwork

A dial is a natural fit for anything that rotates or speeds up. This is another complete sketch with its own setup() and draw(). Read the knob's value in draw() to control your sketch — here the dial sets how fast a square spins. Turn it all the way down to freeze it, or crank it up to make it whirl.

editable — turn the knob to change the spin speed
Tip: The onChange and onRelease callbacks also work on dials — see the MultiDial section for an example that logs values as you turn the knob.

MultiSlider

Fader Bank

A MultiSlider groups several faders together into one unit — like the channel strip on a mixing board or the band controls on a graphic equalizer. All the sliders share the same settings (range, height, style) but can have independent values. One onChange callback fires whenever any of the sliders moves.

Step 1 A bank of sliders in one line

Give the sliders option a set of names and starting values. ProControls creates a separate fader for each one and lines them up side by side. The key (e.g. 'BASS') becomes the label; the number is the starting value.

editable — try adding or removing slider entries
Step 2 Setting the range and size

Use min and max to set the shared value range for all sliders. The height option controls how tall each fader is. Notice that for a classic EQ, we use a negative min and positive max so the center represents "flat" (no boost or cut).

editable — try changing height, min, max, or decimals
Step 3 Mixing styles and using spring-back

Each individual slider can have its own style by passing an object instead of a plain number. You can also set springBack: true on a per-slider basis — that slider will snap back to its starting value when you release it. Try the pitch slider below: drag it and let go!

editable — try changing styles or adding springBack to other sliders
Step 4 Reading all values at once

Unlike a single slider, onChange on a MultiSlider gives you an object with the current value of every slider — not just the one that moved. The keys are the slider labels (spaces and punctuation removed). This makes it easy to read all values in one place, no matter which fader is moving.

editable — move any slider and watch the console
Tip: Access a single slider by name with eq.slider('60Hz').value, or read all values at once with eq.values (returns the same object as onChange).

MultiDial

Knob Bank

A MultiDial is exactly like a MultiSlider, but uses rotary knobs instead of faders. Think of the bass, mid, and treble knobs on a guitar amp or the EQ section of a synthesizer. The knobs sit on a shared panel, and any knob you turn fires the shared onChange callback.

Step 1 A row of knobs in one line

Give the dials option a set of names and starting values — same pattern as MultiSlider. ProControls creates a knob for each entry and places them in a row.

editable — try adding a 'PRESENCE' knob
Step 2 Setting size and range

Use size to control how big each knob is. The min, max, and readout options apply to all knobs at once. Each knob can still have a different starting value.

editable — try changing size or the individual values
Step 3 Different knob styles per dial

Pass an object instead of a number for any dial to override its style (or any other option). This lets you mix different knob looks on the same panel — for example, a rubber knob for volume, a grooved knob for filter cutoff, and a pointer for panning.

editable — try swapping the styles around
Step 4 Reading all values at once

Just like MultiSlider, the onChange callback receives an object with every knob's current value — no matter which one you turned. Turn any knob in the example below to see all three values update together.

editable — turn any knob and watch the console
Tip: Access a single knob by name with tone.dial('BASS').value, or set multiple values at once: tone.values = { BASS: 80, MID: 40 }.

RangeSlider

Range Select

A RangeSlider has two handles — a low one and a high one — that define a range. You might use it to let the user select a frequency range for a filter, a time window to zoom into, or a brightness range for an image. The two handles cannot cross each other. Scroll the mouse wheel over either handle to adjust that end of the range.

Step 1 Your first range slider

Create a RangeSlider with no options and you get two handles at the bottom and top of the track. The colored region between them is the selected range. Drag either handle to resize the range.

editable — changes update the preview
Step 2 Customizing the range

Use valueLow and valueHigh to set where the two handles start. The range is shown numerically next to each handle. Here we model a bandpass filter where you pick a low-cut and high-cut frequency.

editable — try changing valueLow, valueHigh, min, or max
Step 3 Horizontal orientation

Set horizontal: true to flip the slider on its side — the left handle sets the low end and the right handle sets the high end. This layout works well for selecting a time window, a brightness range, or anything where left-to-right makes more intuitive sense.

editable — try changing valueLow and valueHigh
Step 4 Reading both values

The onChange callback for a RangeSlider receives two arguments: lo (the low handle value) and hi (the high handle value). Drag either handle in the example below and watch both values update in the console.

editable — drag either handle and watch the console
Tip: Read the handles programmatically at any time with filter.valueLow and filter.valueHigh — for example inside your draw() loop to apply the range to whatever you are drawing.