# Gui templates

**URL:** <https://forum.defold.com/t/gui-templates/68814>\
**Category:** Questions\
**Created:** [July 9, 2021, 12:23pm UTC](https://forum.defold.com/t/gui-templates/68814 "2021-07-09T12:23:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamika](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/tamika/32/25530_2.png) [@Tamika](https://forum.defold.com/u/Tamika)\
**Post date:** [July 9, 2021, 12:23pm UTC](https://forum.defold.com/t/gui-templates/68814/1 "2021-07-09T12:23:42Z")

</div>

Hi everybody!

I have some problems with gui templates 🙂  
My situation: I have a gui, which have root and child - one template “event\_button”. And in code buttons created, added and etc. And now I need to add new type of button - “score\_button”, which has another template “score\_button”.  
In code I create one event\_button, then one score\_button. And the problem is - event\_button on screen consist both buttons - event and score. How templates works? I thought that template doesn’t exist actually, only when I added it in code. But practically both buttons appears… Where I’m wrong?  
Node hierarchy below:

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/8/4/84a94118b8751085c870768f06ec09abb8025b34.png)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 9, 2021, 2:21pm UTC](https://forum.defold.com/t/gui-templates/68814/2 "2021-07-09T14:21:31Z")

</div>

> [@Tamika](#):
>
> How templates works? I thought that template doesn’t exist actually, only when I added it in code

No, a template exists as soon as it is added to a .gui. The purpose of template files is to allow you to define a button in one place and then reuse the design in multiple places. And when you change the template all places where it is used will be updated.

---

<div class="post-metadata">

**Author:** ![Tamika](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/tamika/32/25530_2.png) [@Tamika](https://forum.defold.com/u/Tamika)\
**Post date:** [July 12, 2021, 7:27am UTC](https://forum.defold.com/t/gui-templates/68814/3 "2021-07-12T07:27:48Z")

</div>

Oh… So, can you please help me with this? How can I use two templates, but show them “customly”? ((

---

<div class="post-metadata">

**Author:** ![Tamika](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/tamika/32/25530_2.png) [@Tamika](https://forum.defold.com/u/Tamika)\
**Post date:** [July 12, 2021, 7:28am UTC](https://forum.defold.com/t/gui-templates/68814/4 "2021-07-12T07:28:53Z")

</div>

And by the way, why when I added score\_button, event\_button didn’t added?..

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [July 12, 2021, 11:26am UTC](https://forum.defold.com/t/gui-templates/68814/5 "2021-07-12T11:26:16Z")

</div>

> [@Tamika](#):
>
> How can I use two templates, but show them “customly”?

Add one instance of each template to your GUI scene and start by disabling both using gui.set\_enabled(node, false). You can then enable them as needed or use gui.clone\_tree(node) to clone the nodes if you need more instances.
