Post

#PowerPlatformTip 130: 'Build Apps Faster with YAML'

#PowerPlatformTip 130: 'Build Apps Faster with YAML'

TL;DR: Every control in Power Apps Studio has a YAML representation. Right-click a finished control, select View code > Copy code, keep the YAML in your own snippet library, and paste it into any other app with Ctrl+V or Paste code. A navigation bar, a popup or a styled form is back in seconds, including all formulas.

You built a nice navigation bar or confirmation popup once. In the next app you rebuild it by hand, control by control. Studio can copy controls as text, so you can store and reuse them like code snippets.

💡 Challenge

You need a good-looking app quickly, but there is no component library in the environment and no template app that fits. Rebuilding the same header, navigation and dialogs in every app costs hours and the apps end up looking slightly different each time.

✅ Solution

Use code view. Studio shows the code of every control in a YAML-based format, including all child controls. You can copy that code out of Studio, store it anywhere as text, and paste it back into any screen of any app. Studio validates the code before it creates the controls.

🔧 How It’s Done

1. Copy a finished control as YAML.

🔸 Open the app in Power Apps Studio, right-click the control (or its container) in the tree view and select View code.

🔸 Select Copy code. The code contains the control and all its children.

2. Store it in your snippet library.

🔸 Save the YAML in a text file, a Git repository or a SharePoint list. A simple navigation bar looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
- conNavBar:
    Control: GroupContainer
    Variant: ManualLayout
    Properties:
      Fill: =RGBA(0, 120, 212, 1)
      Height: =64
      Width: =Parent.Width
    Children:
      - btnHome:
          Control: Classic/Button
          Properties:
            OnSelect: =Navigate(scrHome)
            Text: ="Home"
            X: =16
            Y: =12
      - btnOrders:
          Control: Classic/Button
          Properties:
            OnSelect: =Navigate(scrOrders)
            Text: ="Orders"
            X: =192
            Y: =12

🔸 Every property value is a Power Fx formula and starts with =. Only properties that differ from the default are listed.

🔸 Studio adds a version after the control type when it copies, for example Classic/Button@.... Keep whatever Studio generated in your snippets.

3. Paste it into the target app.

🔸 Select the screen or container in the tree view, then press Ctrl+V or right-click and select Paste code.

🔸 The first time, the browser asks for clipboard access. Allow it, otherwise pasting fails.

4. Adapt the formulas.

🔸 Fix references that don’t exist in the new app, such as scrOrders or a data source name. Studio shows them as formula errors right after pasting.

🎉 Result

Your navigation bar, dialogs and form layouts come back in seconds, with identical styling and working formulas, in every new app.

🌟 Key Advantages

🔸 Reuse without a component library: plain text snippets, no extra setup.

🔸 Formulas included: behavior is copied together with the layout.

🔸 Readable: you can review and compare snippets like any other code.

⚠️ Good to Know

🔸 You can’t edit code inside the code view popup. Edit the YAML in a text editor and paste the new version.

🔸 The App object can’t be copied or pasted this way.

🔸 Snippets from the early preview format of code view no longer paste. Copy them again from a current Studio session.

🎥 Video Tutorial

🛠️ FAQ

1. What is YAML and why use it in Power Apps?

YAML is a human-readable text format. Power Apps Studio uses a subset of YAML to describe controls, their properties and their Power Fx formulas, which makes controls copyable as text.

2. Why does Paste code fail?

Most often the browser blocks clipboard access. In Microsoft Edge, add https://make.powerapps.com to the sites allowed to access the clipboard. Otherwise the YAML is invalid, for example because of broken indentation after editing.

3. Is this the same as the .pa.yaml source files?

It’s the same format family. The .pa.yaml files in the Src folder of an .msapp are read-only and meant for source control review. For reuse, copy and paste through code view.

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.