Skip to content

Button Confirm ​

The ui-btn-confirm widget shows a full-width button with a label and an optional icon. The button has two states, normal and pressed. Each time the user activates it, the widget sends true (normal to pressed) or false (pressed to normal) and switches to the other state. The label, the icon and the confirmation text can differ between the two states.

When Confirmation text is set, pressing the button first opens a dialog titled with the current button label, with the confirmation text, a cancel button and a confirm button. Cancel, or the close button in the dialog header, closes it without sending anything. When Confirmation text is empty, the button sends at once in both states, even if On-Click Confirmation text is set.

Button Confirm

Button Confirm 2

Palette: category Utils, label button confirm. 1 input, 1 output.

Configuration ​

PropertyDescriptionDefault
NameNode name shown in the editor.""
GroupDashboard group where the button is displayed.(required)
SizeWidget width and height; 0 means automatic.0 x 0
LabelButton text in the normal state.""
Icon (mdi)Material Design icon shown before the text in the normal state, for example mdi-play.""
On-Click LabelButton text in the pressed state. When empty, Label is kept.""
On-Click Icon (mdi)Icon in the pressed state, for example mdi-stop. When empty, Icon (mdi) is kept.""
Confirmation textDialog text in the normal state. When empty, no dialog is shown in either state.""
On-Click Confirmation textDialog text in the pressed state. When empty, Confirmation text is shown.""
Cancel button textText of the dialog button that closes it without sending.CANCEL
Confirm button textText of the dialog button that confirms and sends.CONFIRM

Input ​

PropertyTypeEffect
msg.payload.statusbooleantrue puts the button in the pressed state, false in the normal state. Nothing is sent.
msg.enabledbooleanfalse greys the button out and ignores clicks; true enables it again.

Both properties can come in the same message, and the change applies in every open dashboard. When a browser opens or reloads the page, the widget applies the payload.status and enabled of the last message stored for it.

A click changes the state only in the browser where it happened. To keep several dashboards in step with the real state, send payload.status back to the input (see the example).

Output ​

One message each time the user confirms, or presses the button when there is no dialog:

js
{ payload: true }    // normal state -> pressed state
{ payload: false }   // pressed state -> normal state

Input messages are not passed to the output.

Usage example ​

A start/stop button with confirmation in both states:

PropertyValue
LabelStart process
Icon (mdi)mdi-play
Confirmation textStart the process?
On-Click LabelStop process
On-Click Icon (mdi)mdi-stop
On-Click Confirmation textStop the process?

Confirming "Start the process?" sends msg.payload = true and the button shows Stop process. Confirming "Stop the process?" sends false and the button shows Start process again.

When the process reports its state (msg.payload is true while it runs), a function node wired to the button input keeps every open dashboard showing it, and disables the button while the process is in an alarm state:

js
msg.enabled = !flow.get("alarm");
msg.payload = { status: msg.payload === true };
return msg;