Skip to Content
CardsAction Button (New)

Action Button Card

This feature is only available in ESP-DASH Pro
PreviewPreview

The Action Button Card is a confirmation button, typically used for actions that require user approval (e.g., “Are you sure?”).

Initializer

To create an action button card, use the dash::ActionButtonCard class:

dash::ActionButtonCard actionButton(dashboard, "Restart Device", "Are you sure you want to restart the device?", "This action will restart the device and any unsaved data will be lost.");

The initializer takes the following parameters:

  • dashboard: The dashboard instance to which this card belongs.
  • name: The name of the action button (e.g., “Restart Device”).
  • dialogTitle: The title of the confirmation dialog (e.g., “Are you sure you want to restart the device?”).
  • dialogMessage: The message displayed in the confirmation dialog (e.g., “This action will restart the device and any unsaved data will be lost.”).

Methods

💡

The Action Button Card is primarily event-driven and does not have additional user-facing methods beyond the callback.

Callback

Register a callback to handle user confirmation or cancellation from the dashboard UI.

actionButton.onAction([](bool confirm) { if (confirm) { Serial.println("Action confirmed!"); } else { Serial.println("Action cancelled."); } });
  • Signature: void callback(bool confirm)
  • Parameter: bool confirm — True if the user confirmed, false if user clicked cancel button.
  • Description: Called when the user interacts with the action button (e.g., confirms or cancels an action).

Reference

// ... dash::ActionButtonCard actionButton(dashboard, "Restart Device", "Are you sure you want to restart the device?", "This action will restart the device and any unsaved data will be lost."); void setup() { // ... actionButton.onAction([](bool confirm) { if (confirm) { Serial.println("Action confirmed!"); } else { Serial.println("Action cancelled."); } }); } void loop() { // ... }
Last updated on
Copyright © 2025 Softt. All rights reserved.