Skip to content

SetTheme

Defines the theme to use for application.

All the properties defined under Action are applicable to this action.

SetTheme Properties

Property Type Required
Theme string Yes
_Type const Yes

Theme

The theme name to be set. No need to specify .dark or .light if appearance specific theme file is provided.

Examples: "MyBlueTheme", "MyRedTheme"

  • type: string

_Type

  • type: const

The value of this property must be:

"Action.Type.SetTheme"

Action Result

Refer to the MDK Guide to understand what an action result is.

The success ActionResult of this action is the theme name applied. The failure ActionResult is an error message.


Examples

{
    "_Type": "Action.Type.SetTheme",
    "Theme":"#Page:StyleExamples/#Control:lprStyleAction/#SelectedValue",
    "ActionResult":{
        "_Name": "_setTheme"
    },
    "OnFailure":"/MDKDevApp/Rules/Styles/HandleInvalidTheme.js"
}
function setAppTheme(context) {
  try {
      context.setTheme(selectedTheme);
  } catch (error) {
    let message = error.message;
    let title = 'SetTheme Failed';
    alert({'errorMessage':title+':'+message});
  }
}