Out of the box PowerApps provides several options for styling your application with pre-built themes
There are several ways to apply styles. Apply a style directly to each individual component using the property panel.
Or by using the Advanced tab of the Property Panel
Create a settings Screen ( Master Screen) , this screen is never shown to the users of your app, it is only available in the Designer.
Set the properties of the controls in the main app to the properties of the Master screen's controls.
Now any changes made to the Master control automatically updates the app controls.
You can import an Excel SpreadSheet with color values and set the properties of the controls based on the values in the Spreadsheet.
Connect with a SharePoint list that contains the color values, use values stored in a Collection etc...
These options are great when you are in Design Mode, but what about when the app is published?
What if the user wants to change your color scheme?
What if the user would like to set their own colors to match their branding?
PowerApps does not provide this out of the box, you the designer, must provide this functionality. Ideally you would like to build something that can be included in any app in a simple but consistent way.
First Attempt At Creating A Reusable Control
About 9 months ago I created a test app I called "Theme Configurator".
The Theme Configurator was developed before components were made available. Therefore to use in other PowerApps, you have to copy and paste the controls and formulas into the new app, import the SpreadSheet, fix any issues that may surface. Anytime you make a change to the Spreadsheet you would need import it once again and possibly troubleshoot once again. There has to be a better way.
The Better Way is Components!
Components are an Experimental feature recently made available by the PowerApps team.
You have to enable this experimental feature by navigating to your apps settings panel,
File->App settings->Advanced Settings then scroll all the way to the bottom under Experimental Features and click the toggle button for Components.
In this post I created a single app to serve as a Component Library, then I save it to a location easy to find and then import the Component Library instead of copying and pasting the individual controls to my PowerApps.
Theme Component Requirements
Designer / User should be able to input a color by name or by Hex value
Color swatch should show the selected color and another swatch should show the color hue
Slider control adjusts the color hue
Toggle button turns the color on or off (If off, the app will use the default colors)
User settings should be saved to the device if in Offline mode or a SharePoint list if in Online mode.
Should provide reference links to sites containing color values.
The toggle button controls whether to show or hide the chosen color, if the toggle button is set to False then the default color of the Hue Swatch Fill is set, in this case, to AntiqueWhite.
Using the ColorFade function we set the Fill value of the swatch by dividing the result of the Value function by 100, 100 could be repaced with any number you wish.
Repeat for each Hue Swatch and slider pair.
Save the Settings!
Save to the Device!
Saving to the device is a good option where you want all instances of the app to be consistent or if you, the designer, allow it, the user can make all the changes they wish to their app instance without affecting other user instances, or for offline scenarios.
Let's create a Collection to hold the users preferences and then save the Collection to the device using the SaveData function:
// This is the collection that is saved to the Device, add the settings accordingly
// Can only use SaveData on an actual device, does not work in a web browser.
We save the Fill value of the Hue Swatch and associate the value with a key i.e. key= HeaderBackground , value = HdrColorSwatchNew.Fill
This collection keys will be used by the Parent app to dynamically set values of other controls in our app.
We don't need to save the values of the HUE sliders here, instead we just use the Fill values of the HUE Swatches.
Use the Saved Theme in The Main App
In the App OnStart property:
// Load User Theme
4. Button Color = First(SavedTheme).ButtonTextColor
5. Button Fill = First(SavedTheme).ButtonColor
6. Gallery Fill = First(SavedTheme).GalleryBackgroundColor
7. Canvas Fill = First(SavedTheme).CanvasColor
I kind of skipped this when we created the SavedTheme Collection, we need to not only save the color values, but we also need to save the Hex# or Color name the user put into the respective text box.
NOTE: When you save a color or fill in PowerApps, it is saved as an RGBA value (RGBA(32, 54, 71, 1), in this case the RGBA is saved to the Collection, this is not the same as a text value. Currently there is no way to convert an RGBA value to text that I know of yet. You cannot put an RGBA value into the Text property of a Text control.
But we can overcome this, the last 6 key pairs in the SavedTheme Collection are the text values, these values could be the Hex or Color name value.