Cards
Push Button Card
A stateless button that runs a callback on the device each time it is pressed.
ESP-DASH Pro feature. This functionality is available only in the commercial edition of ESP-DASH.The push button card runs a callback on the device each time the user presses it. It is stateless: it holds no value and sends no data other than the press event. Use it to trigger one-shot actions such as starting a measurement or resetting a counter.

Constructor
dash::PushButtonCard(ESPDash& dashboard, const char* name);Prop
Type
dash::PushButtonCard pushButton(dashboard, "Push Button");An overload without the dashboard argument creates the card without attaching it to a dashboard; attach it later with dashboard.add(card).
Callback
void onPush(std::function<void()> callback);The callback fires each time the user presses the button. It receives no arguments. Because the card has no value, no dashboard update is required inside the callback.
pushButton.onPush([]() {
Serial.println("Push button pressed");
});Example
#include <Arduino.h>
#include <WiFi.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <ESPDashPro.h>
AsyncWebServer server(80);
ESPDash dashboard(server);
dash::PushButtonCard pushButton(dashboard, "Reset Counter");
uint32_t counter = 0;
void setup() {
Serial.begin(115200);
// ... connect to WiFi
pushButton.onPush([]() {
counter = 0;
Serial.println("Counter reset");
});
server.begin();
}
void loop() {
// ...
}