Level Up Your Power Apps Design: Adding Gradient Backgrounds with HTML and CSS

Have you ever seen those sleek gradient backgrounds in apps and wished you could add them to your Power Apps creations? Well, you absolutely can! It's surprisingly simple using the HTML control and a touch of CSS magic. Let's dive into a step-by-step guide to enhance your app's visual appeal:

Step 1: Design Your App

Start by creating your Power App and laying out all the essential elements. For this example, let's imagine we're inspired by a design on Dribbble (like this one: https://dribbble.com/shots/24692535-Online-Education-Mobile-app ) and want to create a visually similar app (the middle view).

Organize your components within containers for a structured layout (e.g., Header, Main, Footer). I recommend setting the screen background to black to make white labels pop! Please note I am using a responsive design automatically generated when creating a new Power Apps using “Start with Data” option.

Step 2: Unleash the HTML Control

Now for the exciting part! Add an HTML control directly to your screen (not inside any container). This control will be the canvas for our gradient background.

Step 3: The CSS Gradient Code

Paste the following code into your HTML control's properties:

"<div style='width:" & Self.Width & "px;" & "height: " & Self.Height - 1 & "px;  
  background-color: #000000;
background-image: linear-gradient(315deg, #000000 0%, #5e5368 74%);'>"

Key Points:

Self.Width and Self.Height: We're dynamically setting the width and height of our HTML content to match the control's dimensions. Using Self.Height - 1 prevents an unnecessary scrollbar from appearing.

Step 4: Seamless Integration

To ensure our gradient background blends perfectly, set the HTML control's Width and Height properties to inherit from its parent (the screen):

Width:

Parent.Width

Height:

Parent.Height + 1

Notice the + 1 added to the Parent's height? This clever trick eliminates a thin line that might appear at the bottom of the HTML control.

Step 5: Gradient Glory!

And that's it! You've successfully injected a vibrant gradient background into your Power App. Experiment with different CSS linear gradient values to match your app's design theme. Here are a few examples to get you started:

"<div style='width:" & Self.Width & "px;" & "height: " & Self.Height - 1 & "px;  
  background-color: #39ff14;;
background-image: linear-gradient(147deg, #39ff14 0%, #000000 74%);'>"
"<div style='width:" & Self.Width & "px;" & "height: " & Self.Height - 1 & "px;  
  background-color: #ff7878;
background-image: linear-gradient(315deg, #ff7878 0%, #74d680 74%);'>"
"<div style='width:" & Self.Width & "px;" & "height: " & Self.Height - 1 & "px;  
  background-color: #ff7878;
background-image: linear-gradient(315deg, #ff7878 0%, #74d680 74%);'>"
"<div style='width:" & Self.Width & "px;" & "height: " & Self.Height - 1 & "px;  
  background-color: #FFFFFF;
background-image: linear-gradient(180deg, #FFFFFF 0%, #6284FF 50%, #FF0000 100%);'>"
"<div style='width:" & Self.Width & "px;" & "height: " & Self.Height - 1 & "px;  
  background-color: #85FFBD;
background-image: linear-gradient(45deg, #85FFBD 0%, #FFFB7D 100%);'>"

Now go forth and create visually stunning Power Apps that will impress your users!

Previous
Previous

Power Apps Maps: Unlocking Location-Based Points and Polygons

Next
Next

Add a Touch of Magic to Your Power Apps with Animated SVGs