Horizontal Slider
A horizontal continuous-value control. Drag the thumb to set a value; your sketch gets it live during the drag, or once on release — your choice.
[image] Horizontal Slider on canvas at 50%, green active track, value displayed below
What it does
Horizontal Slider reports a number in a range you define (default 0–100). It can be continuous or stepped. Your sketch reacts on every change during the drag (WHEN_CHANGING(v)) or only when the user releases (WHEN_CHANGED(v)).
When to use it
- LED dimmer — Range 0–100, label Brightness. Use
WHEN_CHANGING(v)to update a PWM pin live. - Motor speed setpoint — Use
WHEN_CHANGED(v)only — applies the new setpoint when the user lets go, no jitter.
Properties
The Inspector opens as a bottom sheet with a Widget ID field at the top, then these sections in order.
Widget ID
| Property | Type | What it controls |
|---|---|---|
| Widget ID | text | Identifier used by your sketch (IHorizontalSlider("…")). |
1. Essential
| Property | Type | Default | What it controls |
|---|---|---|---|
| Enabled | toggle | on | Allow user interaction. |
| Target Devices | multi-select dropdown | — | Pick which device(s) this widget communicates with. Server Mode only. |
2. Header
| Property | Type | Default | What it controls |
|---|---|---|---|
| Show header | toggle | off | Display a text label above the slider. |
| Header text | text | empty (placeholder Enter header text…) | Header text. Only when Show header is on. |
| Alignment | Left / Center / Right | Center | Header text position. Only when Show header is on. |
3. Value
| Property | Type | Default | What it controls |
|---|---|---|---|
| Current value | slider | 0 | Live position of the thumb, between Minimum and Maximum. |
| Minimum | number | 0 | Lower bound of the range. |
| Maximum | number | 100 | Upper bound of the range. |
| Steps (0 = continuous) | 0–100 | 0 | Discretization. 0 = continuous; N = N+1 evenly-spaced stops. |
4. Format
| Property | Type | Default | What it controls |
|---|---|---|---|
| Show value | toggle | on | Display the current value below the slider. |
| Unit | text | empty (placeholder e.g. %, V, °C…) | Unit appended to the displayed value. |
| Decimals | 0–5 | 0 | Decimal places shown. |
5. Appearance
| Property | Type | Default | What it controls |
|---|---|---|---|
| Auto scale | toggle | on | Auto-fit thumb and track to the available space. |
| Track height | 4–24 px | 6 | Track stroke width. |
| Thumb size | 16–64 px | 24 | Thumb diameter. |
| Elevation | 0–16 | 4 | Visual depth. |
6. Colors · Default
| Property | Type | What it controls |
|---|---|---|
| Track | color | Inactive portion. |
| Active track | color | Filled portion under the thumb. |
| Thumb | color | Thumb color at rest. |
7. Colors · Dragging
| Property | Type | What it controls |
|---|---|---|
| Track | color | Inactive portion while held. |
| Active track | color | Filled portion while held. |
| Thumb | color | Thumb color while held. |
States and behavior
[image] Slider at rest (thumb 50%) and during drag (thumb highlighted, dragging colors)
Two visual states: Idle and Dragging. The Dragging color set is independent so you can visually emphasize the live interaction (e.g. brighten the track while held).
When Steps is 0, the value updates continuously. With Steps set to N, the thumb snaps to N+1 evenly-spaced stops between Min and Max.
In code
The slider mirrors the user’s drag on the dashboard. To react to it in your sketch:
IHorizontalSlider("brightness") {
WHEN_CHANGING(v) {
analogWrite(LED_PIN, map(v, 0, 100, 0, 255));
}
};
That’s the minimum — one event block, the value v arrives live during the drag. Use WHEN_CHANGED(v) if you want only the final value on release. See InstantIoT Library / Receive Command from App for details.
Working Arduino code example
A complete sketch you can flash. The Widget ID brightness matches the one you set on your Horizontal Slider in the app.
[gif] Horizontal Slider on the dashboard dimming a LED on the ESP32 — drag updates the brightness in real time
Direct Mode
Your phone connects directly to the ESP32’s SoftAP — no router, no server. Best for prototyping and standalone setups.
#include <InstantIoTWiFiAP.hpp>
const char* AP_SSID = "InstantIoT-Greenhouse";
const char* AP_PASS = "12345678";
#define LED_PIN 2
InstantIoTWiFiAP instant(AP_SSID, AP_PASS);
IHorizontalSlider("brightness") {
WHEN_CHANGING(v) {
analogWrite(LED_PIN, map(v, 0, 100, 0, 255));
}
};
void setup() {
pinMode(LED_PIN, OUTPUT);
instant.begin();
}
void loop() {
instant.loop();
}
Server Mode
The ESP32 connects to your self-hosted InstantIoT Server over WiFi. Multiple devices, persistent state, history.
#include <InstantIoTWiFiServer.hpp>
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
const char* SERVER_IP = "192.168.1.42";
const uint16_t SERVER_PORT = 9001;
const char* DEVICE_TOKEN = "YOUR_DEVICE_TOKEN";
#define LED_PIN 2
InstantIoTWiFiServer instant(SERVER_IP, SERVER_PORT, DEVICE_TOKEN);
IHorizontalSlider("brightness") {
WHEN_CHANGING(v) {
analogWrite(LED_PIN, map(v, 0, 100, 0, 255));
}
};
void setup() {
pinMode(LED_PIN, OUTPUT);
instant.begin(WIFI_SSID, WIFI_PASS);
}
void loop() {
instant.loop();
}
The widget code is identical — only the include and constructor change.
Notes
- For high-frequency sketches (audio, fast PWM), prefer
WHEN_CHANGED(v)— the live drag stream can saturate your link if you process every event. - Value is always a
floatin the macro, even when displayed with 0 decimals.
Next
→ Vertical Slider — Same control, oriented vertically.
→ Joystick — When you need two axes at once.
→ Segmented Switch — When you only want a few discrete options.