Anniversary Sale · up to 80% off all librariesEnds Nov 9Shop now
SOFTTDocs
Cards

Separator Card

Divide the dashboard into labeled sections with a title and subtitle using dash::SeparatorCard.

The separator card is a non-interactive element that divides the dashboard into sections. It displays a prominent title and an optional subtitle above the cards that follow it.

Separator card

Constructor

dash::SeparatorCard<T> card(dashboard, title, initialMessage);

Prop

Type

Template parameters:

Prop

Type

dash::SeparatorCard sensors(dashboard, "Sensors", "Live readings from the environment sensors");
dash::SeparatorCard<const char*> controls(dashboard, "Controls");

An overload without the dashboard argument creates the card without attaching it to a dashboard; attach it later with dashboard.add(card).

Methods

setSubtitle()

bool setSubtitle(const char* subtitle);

Sets the subtitle shown below the title. Returns true if the subtitle changed.

sensors.setSubtitle("Last calibrated at boot");

setValue()

bool setValue(const T& value);

Equivalent to setSubtitle(); the subtitle is the card's value. With T = dash::string, this overload also accepts a dash::string built at runtime.

value()

const T& value() const;

Returns the current subtitle as T (dash::string by default).

setName()

bool setName(const char* name);

Changes the section title set in the constructor. Returns true if the title changed.

Example

main.cpp
#include <Arduino.h>
#include <WiFi.h>              // ESP32; use the networking headers for your board
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <ESPDash.h>

AsyncWebServer server(80);
ESPDash dashboard(server);

dash::SeparatorCard<dash::string> environment(dashboard, "Environment", "Indoor sensors");
dash::TemperatureCard temperature(dashboard, "Temperature");
dash::HumidityCard humidity(dashboard, "Humidity");

void setup() {
  // ... connect to Wi-Fi
  server.begin();
}

void loop() {
  temperature.setValue(23.5f);
  humidity.setValue(55.0f);
  environment.setSubtitle("Updated every 3 seconds");
  dashboard.sendUpdates();
  delay(3000);
}

Notes

  • With T = const char*, the card stores the subtitle pointer and does not copy the string. Pass string literals or buffers that outlive the card.

On this page