A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.
Canvas App YAML - Responsive GridLayout
Read the relevant sections only when a screen uses GroupContainer with Variant: GridLayout. The approved contract fixes content order, shared sizing constraints and required viewport behavior. The builder uses direct metadata and these rules to implement local track formulas and reports budgets from the actual YAML.
Contents
- Core invariants
- Responsive defaults
- Cards-only grid pattern
- Mixed section grid pattern
- Grid troubleshooting
Core invariants
- Derive layout from size, not state. Grid columns, rows, gaps and heights must read
App.Width,Parent.WidthorSelf.Widthdirectly. Do not setvarIsMobile,varColumnsor similar values inOnVisible; Studio and preview can evaluate the layout before that event runs, and the values become stale after a resize. - Set both axes. Every GridLayout sets
LayoutGridColumns,LayoutGridRows,LayoutGridColumnMinWidthandLayoutGridRowMinHeight. A stale or omitted row count can silently force the wrong placement. - Use one column expression. Reuse the same breakpoint expression in
LayoutGridColumns, row-count math, child positions andHeight. Two almost-identical expressions drift into different layouts. - Derive height from rows. For
rows, row heighth, gapg, and vertical paddingpt/pb, useHeight: =rows * h + Max(rows - 1, 0) * g + pt + pb. - Keep grids focused. Put cards and their section labels in GridLayout. Keep nav, breadcrumb, filters, search and data grids in AutoLayout sections unless the approved design explicitly requires one flat grid.
- Use semantic card controls. Use
ModernCardfor card cells, not a stretchedGroupContainer. Assign each image-bearing card a concrete stock-image URL or media asset from the shared plan and set every visible slot. Use a planned AutoLayout surface when the cell is intentionally text-only. - Protect shadows. Give card grids at least 8px padding on every side where a shadow can render.
- Position consistently. Auto-flow is fine for a uniform card set. If any child uses
LayoutGridColumnStart,LayoutGridColumnEnd,LayoutGridRowStartorLayoutGridRowEnd, position every child explicitly; mixing positioned and auto-flow children is unreliable.
Responsive defaults
Use the approved plan's breakpoints. When none are specified, use these app-level defaults:
cols = If(App.Width < 640, 1, If(App.Width < 1024, 2, 3))
pad = If(App.Width < 640, 16, 40)
cardHeight = If(App.Width < 640, 160, 180)
gap = 16
640 separates phone layouts from larger widths; 1024 separates tablet from desktop.
For a reusable nested component, use its available Parent.Width instead of App.Width.
Cards-only grid pattern
For three cards:
- [Prefix]CardGrid:
Control: GroupContainer
Variant: GridLayout
Properties:
DropShadow: =DropShadow.None
FillPortions: =0
LayoutGap: =16
LayoutGridColumns: =If(App.Width < 640, 1, If(App.Width < 1024, 2, 3))
LayoutGridRows: =RoundUp(3 / If(App.Width < 640, 1, If(App.Width < 1024, 2, 3)), 0)
LayoutGridRowMinHeight: =If(App.Width < 640, 160, 180)
LayoutGridColumnMinWidth: =(Parent.Width - 2 * If(App.Width < 640, 16, 40) - (If(App.Width < 640, 1, If(App.Width < 1024, 2, 3)) - 1) * 16) / If(App.Width < 640, 1, If(App.Width < 1024, 2, 3))
PaddingTop: =8
PaddingBottom: =48
PaddingLeft: =If(App.Width < 640, 16, 40)
PaddingRight: =If(App.Width < 640, 16, 40)
Height: =RoundUp(3 / If(App.Width < 640, 1, If(App.Width < 1024, 2, 3)), 0) * If(App.Width < 640, 160, 180) + Max(RoundUp(3 / If(App.Width < 640, 1, If(App.Width < 1024, 2, 3)), 0) - 1, 0) * 16 + 8 + 48
Width: =Parent.Width
Replace every 3 with the actual card count. Do not change only
LayoutGridColumns; rows and height must change with it.
Mixed section grid pattern
Use one flat grid only when the approved design requires labelled sections in a single
GridLayout. Direct children are section-label ModernText controls and ModernCard
controls.
- Give every child explicit responsive column and row start/end formulas.
- Make a section label span the full grid:
LayoutGridColumnStart: =1andLayoutGridColumnEnd: =If(App.Width < 640, 2, If(App.Width < 1024, 3, 4))for a 1/2/3-column grid. - For variable visual heights, use fine row tracks. With track height
8and gap16, a child of desired heightheightspansRound((height + 16) / 24, 0)tracks. The rendered height istracks * 8 + (tracks - 1) * 16. - Walk the fixed child sequence separately at phone, tablet and desktop widths, then write responsive start/end formulas from those positions.
- Compute
LayoutGridRowsfrom the last occupied track and deriveHeightfrom that same value.
This pattern is fragile. Derive the track map from the approved content order and prove that every child fits at each reachable branch. Escalate incompatible composition constraints; do not require the planner to prewrite a second copy of the local grid formulas.
Grid troubleshooting
- Cards overlap or jump columns:
LayoutGridRowsdoes not match the row-count expression, or positioned and auto-flow children were mixed. - Large empty area below the grid:
Heightuses a larger per-row multiplier thanLayoutGridRowMinHeight, or adds padding twice. - Card shadows are clipped: add at least 8px padding on the clipped sides.
- Text clips inside a card: use
AutoHeight: =true, or set zero vertical text padding and make fixed text height at leastSize * 1.5. - Grid responds only after navigation: a layout property depends on a variable set in
OnVisible; replace it with a direct width expression.