Widget Size
Set the responsive width of cards and charts per screen-size breakpoint with setSize() in ESP-DASH Pro.
ESP-DASH Pro feature. This functionality is available only in the commercial edition of ESP-DASH.The dashboard uses a responsive 12-column grid. With setSize() you set how many columns a card or chart occupies at each screen-size breakpoint, without modifying the dashboard webpage.

Breakpoints
Each breakpoint accepts a column count from 1 to 12. A value of 12 makes the widget span the full width of the dashboard at that breakpoint; 6 makes it span half the width.
| Breakpoint | Target screen | Default (cards) | Default (charts) |
|---|---|---|---|
xs | Small smartphone | 12 | 12 |
sm | Smartphone | 12 | 12 |
md | Tablet | 6 | 12 |
lg | HD laptop | 4 | 6 |
xl | Full HD laptop | 3 | 6 |
xxl | 2K display and above | 2 | 4 |
The defaults apply to every widget whose size has not been set with setSize().
Methods
setSize() is available on all cards and charts (every class derived from dash::Widget). Statistics and tabs do not have a size.
setSize with individual values
bool setSize(uint8_t xs, uint8_t sm, uint8_t md, uint8_t lg, uint8_t xl, uint8_t xxl);card.setSize(12, 12, 6, 4, 3, 2);setSize with a Size structure
typedef struct {
uint8_t xs;
uint8_t sm;
uint8_t md;
uint8_t lg;
uint8_t xl;
uint8_t xxl;
} dash::Widget::Size;
bool setSize(const Size& size);chart.setSize({12, 12, 12, 6, 6, 4});Both overloads return false if the requested size equals the current size. Otherwise they mark the size as changed and return true; the new size is sent to clients on the next call to dashboard.sendUpdates().
Default and full-width sizes
dash::Card and dash::Chart provide two static helpers that return a Size:
defaultSize()returns the default size for that widget family (see the table above).fullSize()returns a size that uses thexsdefault at every breakpoint, which spans all 12 columns unless you override the defaults.
card.setSize(dash::Card::fullSize()); // Full width on every screen
chart.setSize(chart.defaultSize()); // Restore the default chart sizeReading the size
const Size* size() const;Returns the custom size of the widget, or nullptr if setSize() has not been called.
Example
// ...
dash::TemperatureCard temperature(dashboard, "Temperature");
dash::LineChart<const char*, float> history(dashboard, "Temperature History");
void setup() {
// ...
// Half width on tablets, a quarter of the width on laptops and larger
temperature.setSize(12, 12, 6, 3, 3, 3);
// Full width at every breakpoint
history.setSize(history.fullSize());
}Change the default sizes
The defaults are defined as preprocessor macros guarded by #ifndef, so you can override them at compile time. Define the macros for the whole build, not only in your sketch, because the library sources must see the same values. In PlatformIO, use build_flags:
build_flags =
-D DASH_DEFAULT_CARD_SIZE_MD=4
-D DASH_DEFAULT_CHART_SIZE_LG=12The available macros are DASH_DEFAULT_CARD_SIZE_<BP> and DASH_DEFAULT_CHART_SIZE_<BP>, where <BP> is XS, SM, MD, LG, XL or XXL.
