Classes and Instances

Modified on Wed, 22 Jun 2022 at 10:05 AM

Learn to create elements dynamically using classes


All UI Elements have an Action titled "activate" which gives the element an active display property, replacing something like d-none. However, occasionally you will want to create elements dynamically, not just hide and show them on command. In this case you can use the element's instance functionality.


If you convert an element to a Class, the element will have all of the inner structures and styles you have already applied, but there will not actually be an instance of the object until the "constructor" is called.



In this example, this piece of Text does not originally appear on the page. It is only after the Button has been clicked that the Text element is constructed.


In this way, you can create UI elements dynamically, or create multiple instances of the same element. This will also give you the "onconstructed" action which allows you to create actions after the element is constructed on the page.


To change the component back to an already-formed Instance, you can click the Component Menu to find the option to Convert to Instance. If the component is a Class it will appear with a dotted line around it.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article