Skip to content

SetTheme

Defines the theme to use for application.

The properties defined in Action are also applicable to this action.

SetTheme Properties

Property Type Required
Theme string Required
_Type const Required

Theme

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

  • type: string

Theme Examples

"MyBlueTheme"
"MyRedTheme"

_Type

  • type: const

The value of this property must be equal to:

"Action.Type.SetTheme"

Action Result

The ActionResult of this action is the theme name applied or the error message if failed.


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});
  }
}