# Simple push button

**URL:** https://discourse.nodered.org/t/simple-push-button/44357
**Category:** General
**Created:** [18 April 2021 13:27 UTC](https://discourse.nodered.org/t/simple-push-button/44357 "2021-04-18T13:27:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ebolisa](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ebolisa/32/89203_2.png) [@ebolisa](https://discourse.nodered.org/u/ebolisa)
#### Post date: [18 April 2021 13:27 UTC](https://discourse.nodered.org/t/simple-push-button/44357/1 "2021-04-18T13:27:32Z")

</div>

Hi,  
when I start the web page, the button´s label is not shown. It's only shown if the button is pressed and then the it stays on. How do I fix it?  
TIA

```auto
[
    {
        "id": "315df55e.e5e2da",
        "type": "function",
        "z": "9532990d.be7468",
        "name": "With icon on press",
        "func": "if (msg.payload == \"X\")\n{\n msg.payload = \"1\";\n msg.icon = '<font color=\"white\"><i class=\"material-icons\"> check_circle_outline</i></font>'\n}\nelse\n{\n msg.payload = \"0\";\n msg.icon = \"Test push button\";\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "// Code added here will be run once\n",
        "finalize": "",
        "x": 210,
        "y": 160,
        "wires": [
            [
                "f2e2faad.62a68",
                "a957b58f.acad1",
                "4316179.d355a68"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

### Author: ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)
#### Post date: [18 April 2021 18:22 UTC](https://discourse.nodered.org/t/simple-push-button/44357/2 "2021-04-18T18:22:55Z")

</div>

Bit tricky to say with just this code but you will need to either preload the button text or use an inject node to send `msg.payload = 'whatever'` on start up.

The button will have to feed `msg.payload = 'whatever'` or `msg.payload = 'X'` when pressed, or toggled, depending on how you are using the button, in order to update the text & icon.

---

<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: [17 June 2021 18:23 UTC](https://discourse.nodered.org/t/simple-push-button/44357/3 "2021-06-17T18:23:10Z")

</div>

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