Building Responsive Pages with Containers

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 10 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Building Responsive Pages with Containers in Power Apps

Introduction: Why Responsive Design Matters

In the early days of Microsoft Power Apps, building an application meant designing for a specific screen size—usually a tablet or a phone. Developers would manually adjust the X and Y coordinates, height, and width of every single control to ensure they fit correctly on the target device. If a user opened that app on a different screen size or orientation, the layout would either collapse, leave massive empty gaps, or cut off essential information. This approach is no longer sustainable in a world where employees access business data from laptops, tablets, mobile phones, and even ultrawide monitors.

Responsive design is the practice of creating applications that automatically adjust their layout, font size, and control positioning based on the available screen real estate. When you build a responsive app, you are essentially creating a flexible interface that "flows" to fill the space provided by the browser or the device. This is not just a cosmetic preference; it is a fundamental requirement for accessibility and productivity. Users who can view your entire application without excessive scrolling or zooming are significantly more likely to adopt the tool and provide accurate data.

By utilizing containers, you move away from absolute positioning and toward a flow-based layout model. Containers act as structural building blocks that group controls together, allowing them to react to changes in screen size. Mastering this concept is the single most important step in transitioning from a beginner Power Apps maker to a professional application developer. In this lesson, we will explore the architecture of responsive containers, how they interact with each other, and how you can implement them to build professional-grade business software.


Not read yet

The Core Concept: Absolute vs. Responsive Layouts

To understand containers, we must first contrast how traditional Power Apps behave versus how container-based apps function. In a traditional canvas app, every control has a fixed coordinate. If you place a button at X: 100, Y: 100, it stays there regardless of whether the screen is 800 pixels wide or 1920 pixels wide. This leads to the "floating island" effect, where buttons appear to be disconnected from the rest of the form as the screen expands.

Responsive layouts use a "box model" approach, similar to how modern web pages are built using CSS Flexbox. In this model, you define parent containers that hold child controls. These containers are configured to grow, shrink, or wrap based on the screen width. When you resize the browser window, the containers communicate with their children, telling them how much space they are allowed to occupy.

Callout: The Box Model Philosophy The fundamental shift in responsive design is thinking in terms of "relationships" rather than "coordinates." Instead of telling a label, "You are at pixel 50," you tell a container, "You are 50% of the screen width," and then you tell the label, "You are 100% of the container width." This creates a dynamic relationship that persists across any device resolution.

Types of Containers

Power Apps provides two primary types of containers to help you manage layout:

  1. Horizontal Containers: These arrange child controls side-by-side in a row. They are ideal for navigation bars, toolbars, or headers.
  2. Vertical Containers: These arrange child controls stacked one on top of the other in a column. They are perfect for form fields, lists, or content sections.

By nesting these containers—putting a horizontal container inside a vertical one, for example—you can create complex grid-like structures that remain stable regardless of the screen size.


Not read yet

Step-by-Step: Setting Up Your First Responsive App

Before you start adding containers, you must configure the application settings to allow for responsiveness. If these settings are not enabled, your containers will not behave as expected.

Step 1: Enable Responsive Settings

  1. Open your Power App in the Power Apps Studio.
  2. Navigate to Settings > Display.
  3. Ensure Scale to fit is turned Off. This is the most critical step, as it forces the app to render at the native resolution of the screen rather than scaling up or down like an image.
  4. Set Lock aspect ratio and Lock orientation to Off.
  5. Click Save.

Step 2: Adding Your First Container

  1. Select the Insert tab in the ribbon.
  2. Click on Layout and select Vertical container.
  3. Rename the container (e.g., MainContainer) in the tree view.
  4. In the properties panel, set the Width to Parent.Width and the Height to Parent.Height.
  5. Set the X and Y properties to 0.

Note: Whenever you create a container, always bind its dimensions to the parent screen or the parent container. This ensures that if the screen resizes, the container follows suit immediately.

Step 3: Adding Controls to the Container

  1. Drag a label or a button into the MainContainer.
  2. Notice how the container automatically assigns a position to the control. You can no longer drag the control to a specific X/Y coordinate; you must use the container’s alignment settings.
  3. Use the Align (horizontal) and Justify (vertical) properties in the properties panel to move the control within the container.

Not read yet

Deep Dive: Mastering Container Properties

Understanding the specific properties of containers is the key to building complex layouts. These properties control how space is distributed among the items inside the container.

The Flexible Width/Height Property

The most powerful property in a container is the Flexible width (for horizontal containers) or Flexible height (for vertical containers) toggle. When this is set to On, the control will attempt to fill all available space in the container. If you have two controls in a container and both have "Flexible" turned on, they will split the available space equally (50/50).

If you want one control to take up 75% of the space and another to take up 25%, you use the Fill portions property. By setting the first control to a Fill portions value of 3 and the second to a value of 1, the container calculates the ratio and distributes the space accordingly.

Gap and Padding

  • Gap: This property defines the amount of whitespace between child items. Instead of adding a "spacer" control, you simply increase the Gap value to add breathing room between buttons or input fields.
  • Padding: This property adds space between the edge of the container and its contents. If you want your form to look professional, adding a padding of 20 or 30 pixels prevents controls from touching the edges of the screen.

Callout: Container Nesting Best Practices A common mistake is trying to build the entire app layout in a single container. Instead, use a "Header-Body-Footer" architecture. Create one main vertical container that acts as the backbone, then place three separate containers inside it: one for the header, one for the body, and one for the footer. This makes managing the layout much simpler.


Not read yet

Practical Example: Building a Responsive Header

Let’s build a standard header that contains a logo on the left, a navigation menu in the middle, and a user profile icon on the right.

  1. Create a Horizontal Container named HeaderContainer. Set its height to 60.
  2. Set its Width to Parent.Width.
  3. Add an Image control for the logo. Set its Width to 150.
  4. Add a Horizontal Container for the navigation links in the middle. Set its Flexible width to On.
  5. Add an Icon control for the user profile on the far right. Set its Width to 50.

Because the middle container is set to Flexible width, it will automatically expand or shrink to occupy whatever space is left between the logo and the profile icon. This is the definition of a responsive layout.

Code Snippet: Handling Screen Breakpoints

While containers handle the "flow" of controls, sometimes you need to completely change the layout based on the screen size. For example, on a phone, you might want to hide a sidebar, but on a desktop, you want to show it. You can use the App.Size property to handle this.

// Set the Visibility property of a sidebar container
// App.Size 1 = Phone, 2 = Tablet, 3 = Desktop
If(App.Size > 2, true, false)

In this snippet, the sidebar will only appear when the App.Size is greater than 2 (Desktop). This allows you to create different experiences for different devices while keeping the logic contained within the same screen.


Not read yet

Best Practices and Industry Standards

Building responsive apps is as much about discipline as it is about technical skill. Over the years, the Power Apps community has converged on several best practices that lead to cleaner, more maintainable code.

1. Avoid "Hard-Coding"

Never type a specific number for height, width, X, or Y if you can avoid it. Use relative references like Parent.Width, Self.Width, or Container.Width. If you find yourself typing Width: 500 into a property bar, stop and ask yourself if that number should be a percentage of the screen instead.

2. Standardize Your Spacing

Don't randomly pick padding values. Create a "Theme" or "Global Variable" store. In the App.OnStart property, define variables for your spacing:

Set(varSpacing, 20);
Set(varHeaderHeight, 60);

Then, use varSpacing in the padding properties of all your containers. If you decide later that the app needs more breathing room, you can change one variable, and the entire app will update.

3. Use "Gap" Instead of Spacers

Beginners often use transparent rectangles as "spacers" to push controls apart. This is a bad practice because it increases the number of objects the app has to render, which slows down performance. Use the Gap property of the container instead.

4. Keep the Hierarchy Shallow

Try not to nest containers more than 3 or 4 levels deep. If your tree view looks like an endless list of nested containers, the app will become difficult to debug. If you need more depth, consider splitting the content into separate components or different screens.


Not read yet

Comparison Table: Absolute vs. Responsive Design

Feature Absolute Positioning Responsive Containers
Control Movement Manual (Drag and Drop) Automatic (Flow-based)
Responsiveness None (Static) Fluid (Adapts to screen)
Complexity Low (Initially) Moderate (Requires learning)
Maintenance High (Hard to update) Low (Changes propagate)
Performance High (Fewer objects) High (Optimized for rendering)

Common Pitfalls and How to Avoid Them

Pitfall 1: The "Invisible" Container

Sometimes you add a container, but it doesn't appear to have any width or height. This usually happens because you haven't set the Width and Height properties to relative values. If the container's width is set to 0 or a fixed small number, the controls inside it won't be visible.

  • Fix: Always set the Width of a container to Parent.Width or ensure it is inside a parent that has defined dimensions.

Pitfall 2: Overlapping Controls

If you use containers but don't set the Align or Justify properties correctly, controls might overlap.

  • Fix: Ensure your container's Wrap property is set correctly. If you have a horizontal container and you want items to move to the next line when they run out of space, set Wrap to On.

Pitfall 3: Ignoring the "App.Size"

Many developers build a beautiful desktop layout but forget to test it on a phone. The app might look great on a monitor but be unusable on a mobile device because the controls are too small or the layout is squashed.

  • Fix: Use the "Preview" mode in Power Apps Studio and change the device type to "Phone" frequently while you are building. If something looks bad, use the App.Size property to adjust the layout specifically for that breakpoint.

Warning: The "Scale to Fit" Trap Many developers leave "Scale to Fit" enabled because it makes the app look "fine" on all devices instantly. However, this is a trap. It effectively shrinks or stretches your app like a low-quality image. Your text will become blurry, and touch targets will become difficult to hit. Always disable "Scale to Fit" and use containers for a truly professional result.


Not read yet

Advanced Responsive Techniques

Once you are comfortable with containers, you can start using advanced properties to create highly dynamic interfaces.

Using the "Wrap" Property

The Wrap property in a container is one of the most underutilized features. When Wrap is set to On, the container will automatically wrap items to a new row or column if there isn't enough space. This is perfect for building photo galleries or dashboards where the number of items might change dynamically.

Dynamic Visibility

You can combine containers with visibility logic. Imagine a scenario where you have a "Filter" pane on the left. On a desktop, you want it pinned to the side. On a phone, you want it to be a slide-out drawer. You can create a container for the filter pane and change its Width based on a variable:

// Variable toggles between 300 (open) and 0 (closed)
If(varFilterOpen, 300, 0)

By animating the transition or simply toggling the width, you create a seamless user experience that feels like a native mobile app.

Handling Data-Driven Layouts

If you are building a list of items using a Gallery, ensure the Gallery control is placed inside a container. Set the Gallery's Width to Parent.Width. This ensures that even if you have a list of records, the list itself will expand to fill the available screen space, preventing the need for horizontal scrolling on the data grid.


Not read yet

FAQ: Frequently Asked Questions

Q: Does using containers make my app slower? A: Generally, no. Containers are optimized by Microsoft to be rendered efficiently. In fact, using containers can be faster than using dozens of individual controls with complex absolute coordinates, as the browser has less work to do in calculating every single pixel position.

Q: Can I convert an existing "Absolute" app to a "Responsive" app? A: You can, but it is a manual process. You will need to wrap your controls in containers and update their X/Y properties. It is often faster to create a new screen and move the controls over, rather than trying to retrofit an existing, complex screen.

Q: What is the best way to test responsiveness? A: Use the "Preview" button in the top right corner of the Power Apps Studio. You can drag the side of the preview window to see how your app reacts in real-time. This is the most effective way to identify layout breaks before you publish the app to your users.

Q: Should I use containers for everything? A: Not necessarily. Simple apps with one or two buttons don't always need complex container nesting. Use your judgment. If the layout is simple and won't change, absolute positioning is fine. If you expect the app to grow or be used on multiple devices, use containers from the start.


Not read yet

Key Takeaways

  1. Shift Your Mindset: Move away from thinking in fixed coordinates (X, Y) and start thinking in relationships (parent-child, flow, and percentage).
  2. Disable "Scale to Fit": This is the most important setting for professional responsive apps. It forces you to build properly rather than relying on the browser to stretch your app.
  3. Leverage Container Types: Use Horizontal containers for side-by-side layouts and Vertical containers for stacked layouts. Master the nesting of these two types to build any structure you can imagine.
  4. Prioritize Relative Sizing: Always bind control dimensions to Parent.Width or Parent.Height. Avoid hard-coding pixel values whenever possible.
  5. Use the "Gap" Property: Eliminate the need for hidden spacer controls by using the built-in Gap and Padding properties of your containers.
  6. Test at Multiple Breakpoints: Use the App.Size property to create device-specific layouts (Phone vs. Tablet vs. Desktop) to ensure the app is usable on all screens.
  7. Keep It Simple: Don't over-engineer your hierarchy. A clean, shallow container structure is easier to maintain and troubleshoot than a deeply nested, complex one.

By following these principles, you will be able to build Power Apps that not only look professional but also provide a consistent and enjoyable experience for your users, regardless of the device they choose to use. The transition to responsive design is a journey, but once you master containers, you will find that building interfaces becomes faster, more logical, and significantly more rewarding.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.