Components are one of the features of Power Apps that gets used too little. Utilizing components is a great way to build a more maintainable and better performing application.
However, the components as a concept (input, output and behavior parameters) are tilted in the direction of traditional application development. As a result, the threshold for starting to use them may be unnecessarily high for citizen developers.
I have written several posts in my personal blog about working with components. If the topic is unknown, you can start with them
- PowerApps Components (Part 1) – Navigation
- PowerApps Components (Part 2) – Organization Common Footer
- PowerApps – How to implement a dialog box as a reusable component
- Implementing your own choice component
The components have evolved since these posts were written. The biggest single update is the ability to trigger events from a component (behavior property).
This time, however, the focus is not on making the components but rather on how the same component can be utilized in several different applications.
Creating a component
Let’s create an example application with two components inside it (header and footer).
An application that utilizes components looks like this.
The application is the same one we just created these two components into.
Utilizing components in another application
Let’s create another application to which we import the components we just created. This can be done with the import command.
Components can be imported from applications in the same environment (for which you have maker rights).
Now we have a new application that uses the same components as the first application.
But not quite…
Actually, copies of the original components were just created for our new application.
If we were to create a third application and import components there too, we could import the header and footer components from one of the two applications we just created.
When we make changes to components within an application, those changes are in no way visible to other applications that utilize the “same” components.
Not terribly convenient.
Fortunately, it is no longer encouraged either. Exporting and importing components from one application to another is currently disabled by default. The feature will disappear completely at some point.
Creating a component library
The correct and supported way to share components is to utilize a Component library.
Let’s create one in our environment.
When you create a library, it is only given a name.
The Power Apps editor opens for us. Unusually, it opens directly in the component view.
The components are created (or imported from old applications) here.
Remember to save (and publish) when done.
Now we have a new component library in our environment that can contain multiple components. A library can be shared with others just like an application.
Using components from the component library
How are the components in the library utilized?
Let’s create a new application and get the required components with the “Get more components” selector below the control list.
We can select the components needed for our application from the component libraries that are shared with us and are in the same environment.
The selected components are then displayed among the other controls. They can be used in the application in a familiar way.
Note that the components we import do not appear on the application’s own Components tab. They can only be edited in the component library (if you have editing rights).
The Components tab only contains components that are built to use for this specific application and are not shared elsewhere.
The maker of the application cannot modify the components extracted from the library for their use. This is a good thing.
But what happens when the maker of a component updates library components?
Nothing at all until the moment comes when the component library is republished.
For published applications that utilize library components, nothing happens yet. But the next time the application is edited, a notification about the update of the available component libraries will appear on the screen.
The Review button opens a list of updated component libraries. We can choose from the list of which libraries we want to update.
Once we choose to update, we have an updated header component. It’s that easy.
Now we can safely check the functionality of our application with this new updated component. And finally, publish the app so that users can also enjoy the updated component.
I stated at the beginning that components are used very little in Power Apps. And naturally the component libraries are used even less.
The components are extremely useful for internal use in the application. It is much more difficult to come up with use cases, where the same component would be used in several different applications. And that’s what these libraries were created for.
The first thing that comes to mind is the navigation of mobile applications and the generic headers and footers of the applications.
Component libraries, like applications, are always located in one environment. But no worries. They can be added to a solution package.
When creating component libraries, you should keep in mind that the contents of an entire library are always published at once. So it is not possible to publish just one component from the library. All components of the library must be in publish-ready condition when the library is published.
Interested in reading our latest Power Platform blog posts?
You’re welcome to subscribe to our email newsletter: Forward Forever Monthly. Max 1 email per month, with a curated list of latest insights and articles on Power Apps, Power Automate, Power BI.