Skip to main content


Attributes are a way of storing untyped key/value pairs on elements. These generally have two uses: styling and meta data tracking.

An attribute can be set in a few different ways on elements.

As a member declaration

In a top level declaration, you can declare an attribute with the attribute member syntax. attr: followed by the key name of the attribute optionally followed by a value expression. The value expression can be any expression that returns a string, boolean value, or enum value.

template Thing {


attr:abc = "xyz";

attr:someKeyCode = KeyCode.A;

attr:somethingBoolean = true;

attr:someExpression = ComputeSomething();


As an invocation member

When applying an attribute to an element invocation, the same rules/apis apply as in the top level declaration member version.

template Example render {


SomeElement(attr:abc = "xyz");

SomeElement(attr:someKeyCode = KeyCode.A);

SomeElement(attr:somethingBoolean = true);

SomeElement(attr:someExpression = ComputeSomething());

Using an ElementReference

When using an ElementReference to set attributes you instead use the C# api. There is also an api for reading attributes with string GetAttribute(string key) and bool HasAttribute(string key).

elementReference.SetAttribute("key", value);