Use code view for canvas app controls (preview)

[This article is prerelease documentation and is subject to change.]

Use the code view feature to look at the underlying code for each control on your app's screens. The code uses an improved format that's a subset of YAML.

With code view you can:

  • View the code for each control on your screen.
  • Copy the code for a control and share it outside of Power Apps Studio.
  • Paste the code for a control and create a new control based on it.

Important

  • This is a preview feature.
  • Preview features aren't meant for production use and might have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback.

Note

Since this is a preview feature and the format is subject to change. We don't guarantee compatibility with the final version. The current code format seen in the code view isn't suitable for source control during the preview period.

View, copy, and paste code

Code view shows the code for the selected control and all its child controls.

Code view lets you copy and paste code to any screen in your app, or outside of Power Apps, to duplicate the control. This duplication feature is helpful when controls are highly customized and you want to share or duplicate it.

View code

  1. Open your app for editing in Power Apps Studio.

  2. Right-click the control in the tree view or on the screen, and then select View code (preview).

    Screenshot of the tree view in Power Apps Studio, with the View code option on a control's context menu highlighted.

Tip

Use the keyboard shortcut Ctrl+F to find a specific string in the code.

Copy and paste code

  1. When viewing your code in the code view popup, select Copy code.

  2. Share it or paste it to create a duplicate of the selected control:

    • To share it, paste the copied code in any window.
    • To add a new control from the copied code, right-click the screen where you want to add the new control, and then select, Paste code (preview).

    Screenshot of the tree view in Power Apps Studio, with the Paste code option highlighted on a control's context menu.

Important

You must use the YAML format that Power Apps Studio generates. The code is validated before the new control is created.

Known limitations

  • You can't copy and paste or view the code for the App Object.
  • You can't edit the code in the code view.
  • You can only copy controls that are on a screen. You can't copy a screen.
  • When you paste code, the new control is positioned at coordinates X=40, Y=40. In the future, the X and Y properties that you set are respected.