Skip to main content

How to Wrap Controls onto the Next Row in a Horizontal Container in Power Apps

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A horizontal container lines its controls up in a row. On a wide screen that's what you want; on a phone, the row is wider than the screen and the last controls are cut off or disappear. The container's Wrap property moves the controls that don't fit onto the next row, and one formula makes them full width on phones.

The example is the Home screen of the Overtime Timesheet app, where a horizontal container, conActionsHS, holds the app's action buttons: Log overtime, My overtime, Departments and, for some people, more.

Prerequisites​

The Problem: One Row, Too Narrow​

The buttons are 200 pixels wide with a 16-pixel gap. On a phone, here the preview's Apple iPhone 12, 13, 14, three of them don't fit across. With Wrap off, My overtime is cut off at the edge, and Departments isn't visible at all:

A phone preview of the Home screen with Wrap off: the Overtime Timesheet header, Welcome, Admin and Department: Management, then the Log overtime button and the My overtime button cut off at the right edge, with no Departments button

The container's Horizontal Overflow is Hide, so whatever runs past its edge is simply not shown. Scroll would add a scroll bar instead, which people on phones easily miss.

Step 1: Turn On Wrap​

Select the container, here conActionsHS, and in the Properties pane's Display tab, under General, switch Wrap to On:

The Properties pane for the container conActionsHS on its Display tab, with Direction Horizontal, Justify and Align at start, Gap 16, Horizontal Overflow Hide, Vertical Overflow Hide, and Wrap switched On, outlined in red

In formulas, the property is LayoutWrap:

conActionsHS → LayoutWrap
true

Microsoft's Horizontal container reference describes Wrap as defining whether the content wraps to a new row or column when it cannot fit.

Step 2: Check It on a Phone​

Preview the app at a phone size: How to Test a Power Apps Canvas App on Phone and Tablet Sizes. Each button that doesn't fit moves to a new row, and every button is visible:

The same phone preview with Wrap on: Log overtime, My overtime and Departments each on its own row, 200 pixels wide and aligned to the left

On a wide screen, nothing changes: the buttons still sit side by side, because they fit.

Step 3: Make the Controls Full Width on Phones​

The buttons now stack, but at 200 pixels they leave an empty strip down the right. Set each button's Width to the container's width on small screens, and keep 200 elsewhere:

Each button → Width
If(App.ActiveScreen.Size = ScreenSize.Small, Parent.Width, 200)

Set it on one button, then copy the button for the others, so the formula comes along: How to Copy and Paste Controls Between Screens in Power Apps. On the phone, the buttons become one tidy column:

The phone preview with each button full width in one column: Log overtime, My overtime and Departments, under Welcome, Admin and Department: Management

What Wrap Changes for the Container's Other Settings​

  • Align in container is ignored. Microsoft's known issues for responsive layouts say that when a container's Wrap is on, its child controls' Align setting is ignored. Align the rows with the container's own Align instead.
  • The container needs room for the new rows. Rows go downwards, so give the container a flexible height, or set Vertical Overflow to Scroll if the rows might not fit. In the example the container fills the rest of the screen, which has room for every button.

Common Mistakes​

MistakeWhat happensDo this instead
Turning Wrap on in a container with a fixed, short heightThe new rows are hidden below its edgeGive it a flexible height, or Vertical Overflow: Scroll
Setting Align in container on a button inside a wrapping containerThe setting is ignoredUse the container's own Align
Fixed widths onlyWrapped buttons leave an empty strip on phonesUse Parent.Width on small screens
Using Horizontal Overflow: Scroll instead of WrapControls hide behind a sideways scroll barTurn on Wrap

Troubleshooting​

SymptomLikely causeFix
Controls still run off the edgeWrap is off, or the controls are in a different containerSelect the container that holds them and check Wrap
A wrapped row is missingThe container's height is too small and Vertical Overflow is HideLet the container grow, or scroll
Buttons are full width on a tablet tooThe Width formula doesn't test the screen's sizeUse If(App.ActiveScreen.Size = ScreenSize.Small, Parent.Width, 200)

FAQ​

Does a vertical container wrap too?​

Yes, the same property exists there. It moves controls that don't fit into a new column instead of a new row.

Can I control which controls go to the next row?​

Not directly: controls wrap in the order they're in the container. Change the order in the Tree view to change what wraps first: How to Reorder Controls in a Container in Power Apps.

Conclusion​

Turn on the container's Wrap (LayoutWrap = true) and controls that don't fit move onto a new row instead of running off the screen. Add If(App.ActiveScreen.Size = ScreenSize.Small, Parent.Width, 200) to their Width, and on phones they line up as one full-width column.

Additional Resources​