# Maintained buttons

**URL:** <https://discourse.nodered.org/t/maintained-buttons/91049>\
**Category:** Dashboard\
**Created:** [17 September 2024 16:54 UTC](https://discourse.nodered.org/t/maintained-buttons/91049 "2024-09-17T16:54:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nearbyatom](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@nearbyatom](https://discourse.nodered.org/u/nearbyatom)\
**Post date:** [17 September 2024 16:54 UTC](https://discourse.nodered.org/t/maintained-buttons/91049/1 "2024-09-17T16:54:15Z")

</div>

I see the buttons in the UI. How do I get to work like the slider switch?

So if I press the button, sets the payload to true. Press again, set payload to false.

TIA.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 September 2024 17:08 UTC](https://discourse.nodered.org/t/maintained-buttons/91049/2 "2024-09-17T17:08:19Z")

</div>

If you are talking about the new dashboard and can wait a short while, I believe there may be plans to allow the switch node to look like a button.

Alternatively you can get the button to send eg "toggle" and use a function node to toggle a context variable between true and false.

---

<div class="post-metadata">

**Author:** ![nearbyatom](https://avatars.discourse-cdn.com/v4/letter/n/ec9cab/32.png) [@nearbyatom](https://discourse.nodered.org/u/nearbyatom)\
**Post date:** [17 September 2024 18:04 UTC](https://discourse.nodered.org/t/maintained-buttons/91049/3 "2024-09-17T18:04:26Z")

</div>

But what's my payload going to be? Right now, I have just a payload is true when clicked

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec14d24c709949d27fe97aeb70f9b5b22763d841.png)

---

<div class="post-metadata">

**Author:** ![smanjunath211](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/smanjunath211/32/95742_2.png) [@smanjunath211](https://discourse.nodered.org/u/smanjunath211)\
**Post date:** [18 September 2024 01:33 UTC](https://discourse.nodered.org/t/maintained-buttons/91049/4 "2024-09-18T01:33:36Z")

</div>

you could add a contrib node to get alternating output  
`node-red-contrib-toggle`

```auto
[{"id":"1e4ee55fa6e990ee","type":"inject","z":"4cde86148e5b95f7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":228.00001907348633,"y":800.000078201294,"wires":[["c38f433ecd940c54"]]},{"id":"c38f433ecd940c54","type":"toggle","z":"4cde86148e5b95f7","name":"","onOffTopic":"","onValue":"On","onType":"str","offValue":"Off","offType":"str","toggleTopic":"","toggleValue":"","toggleType":"any","passOnOff":"ifChanged","x":353.0000190734863,"y":800.000078201294,"wires":[["24b2eb79b970f701"]]},{"id":"24b2eb79b970f701","type":"switch","z":"4cde86148e5b95f7","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"On","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":478.0000190734863,"y":800.000078201294,"wires":[["4e1c978d3e9b64d6"],["4e1c978d3e9b64d6"]]},{"id":"4e1c978d3e9b64d6","type":"debug","z":"4cde86148e5b95f7","name":"debug 2705","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":658.0000190734863,"y":800.000078201294,"wires":[]}]

```

![toggle](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/4/04585fd91c8d619c8d5502d03e6be5cb7a8794da.gif)

or you could achieve the same in a function node as @jbudd suggested.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 October 2024 01:34 UTC](https://discourse.nodered.org/t/maintained-buttons/91049/5 "2024-10-18T01:34:09Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
