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.


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')


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.


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