Use Environment Theme Colors for your Custom Pages in Model Driven Apps

If you are using custom pages in your model driven apps and would like to use the same colors as the default theme of the environment, this post will answer your question.

/uploads/2023/01/2023-01-31_13-26-54-2.png

Themes table in Data

The table will get added as Themes_1 as there is already a Themes object used for something else on a custom page.

On the App OnStart, set a global variable similar to below. We are filtering to the default theme and then using that record to set the variable.

Set(gblTheme,First(Filter(Themes_1,'Default Theme'='Default Theme (Themes_1)'.Yes)));
Set(gblBtnColor,gblTheme.'Link and Button Text Color')

/uploads/2023/01/2023-01-31_13-43-39-1024x288.png

App OnStart code

If you are already using some variable, you can modify the code above to suit your needs.

Once you have the Theming style defined in a variable, you can use the colors associated with the theme in any of your UI controls. Below example shows how to use it in a button control.

/uploads/2023/01/image-1024x976.png

Button control’s Fill color

Let me know in the comments what you think about this approach or if you another way of doing this.

Did this article help you❓

Subscribe to get more Power Platform articles directly in your inbox