Skip to main content

Styles

Styles get applied to elements either with a style = [..] member or with the C# api.

When used as a template member, styles are referenced via the @ symbol. Referring a style that does not exist is a compiler error.

Even when supplying only 1 style, you still need to use brackets [@styleName]


template StyledThing {

style = [@style1, @style2, @SomeModule::StyleName];

render {
// or as an invocation memember
SomeElement(style = [@style1]);
}

}

C# Api

ElementReference elementRef = SomeHowGetAnElementReference();
StyleId styleId = uiRuntime.GetStyle("ModuleName", "StyleName");
elementRef.styleList.Add(styleId);
elementRef.styleList.Remove(styleId);
elementRef.styleList.Toggle(styleId);