# Setting default values to UI nodes

**URL:** <https://discourse.nodered.org/t/setting-default-values-to-ui-nodes/145>\
**Category:** Dashboard\
**Created:** [13 May 2018 14:25 UTC](https://discourse.nodered.org/t/setting-default-values-to-ui-nodes/145 "2018-05-13T14:25:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![igrowing](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/igrowing/32/663_2.png) [@igrowing](https://discourse.nodered.org/u/igrowing)\
**Post date:** [13 May 2018 14:25 UTC](https://discourse.nodered.org/t/setting-default-values-to-ui-nodes/145/1 "2018-05-13T14:25:51Z")

</div>

Hi, likely this is another FAQ: how to set “default value” or “initial value” to UI elements/nodes?

I’d like to have some switches on and others off when node-red loads.  
And numeric/sliders at certain values each.

I could keep the values in a file, read them on boot into the flow… and… still how to apply to UI nodes?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 May 2018 15:38 UTC](https://discourse.nodered.org/t/setting-default-values-to-ui-nodes/145/2 "2018-05-13T15:38:00Z")

</div>

almost there… just pass them into the relevant ui nodes… only thing to note is that the input to the switch must be of the same type as it is set to send out… so if it send a string “1” then you need to send in a string “1” and not a number 1. Likewise just send the values you want into the slider and numeric to pre-load them.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 May 2018 20:17 UTC](https://discourse.nodered.org/t/setting-default-values-to-ui-nodes/145/3 "2018-05-13T20:17:26Z")

</div>

An alternative to using a file is to use inject nodes set to inject once on startup.

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [12 February 2019 21:16 UTC](https://discourse.nodered.org/t/setting-default-values-to-ui-nodes/145/4 "2019-02-12T21:16:56Z")

</div>

This is a great solution to setting initail values when NR starts. What about when the UI connects? I would like to have a set of initial values each time the user connects. Thanks.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [12 February 2019 21:18 UTC](https://discourse.nodered.org/t/setting-default-values-to-ui-nodes/145/5 "2019-02-12T21:18:54Z")

</div>

th ui\_control node emits a message on many events including a connection - which you can use to trigger setting things if you like
