Cards
You are reading the documentation for ESP-DASH v4.x.x, which is no longer the latest release. View the v5.x.x documentation.Push Button Card
Trigger a stateless action from the ESP-DASH Pro v4 dashboard with the push button card and its callback.
ESP-DASH Pro feature. This functionality is available only in the commercial edition of ESP-DASH.The push button card triggers a callback each time the user clicks it. It is stateless, which makes it suitable for one-shot actions such as restarting a device or starting a task.

Constructor
Card pushButton(&dashboard, PUSH_BUTTON_CARD, "Restart");Prop
Type
Callback
The callback takes no arguments and fires on every click. Because the button has no state, no update() or dashboard.sendUpdates() call is required.
pushButton.attachCallback([&]() {
Serial.println("Push button clicked");
});Example
#include <Arduino.h>
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#elif defined(ESP32)
#include <WiFi.h>
#include <AsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>
#include <ESPDash.h>
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
AsyncWebServer server(80);
ESPDash dashboard(&server);
bool restartRequested = false;
Card pushButton(&dashboard, PUSH_BUTTON_CARD, "Restart");
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi connection failed");
return;
}
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
pushButton.attachCallback([&]() {
restartRequested = true;
});
server.begin();
}
void loop() {
if (restartRequested) {
delay(100);
ESP.restart();
}
}Notes
- The push button card does not need
update(), since no value is passed back to the dashboard.