Crafting Reusable Power Apps Components: 5 Practical Examples
Reduce repetitive work and improve consistency by building encapsulated components for your canvas apps.
Component reuse is one of the quickest ways to reduce repetitive work and keep your apps consistent. By encapsulating a piece of UI together with its logic inside a canvas component, you build a building block that can be placed on any screen and even shared across app projects. In this guide we’ll walk through creating five components for a company called Contoso Corp that wants to standardise its customer portal. Each component introduces a new concept: input and output properties, behavioural properties, component‑level context variables, and component libraries.
Scenario: Standardising a Customer Portal
Contoso runs a feedback and order‑tracking app. The core data looks like this:
| Table | Key fields |
|---|---|
| CustomerFeedback | FeedbackID, CustomerName, Rating (1‑5), Comments, CreatedDate |
| Products | ProductID, ProductName, Category |
| Orders | OrderID, CustomerName, ProductName, OrderStatus, OrderDate |
We’ll build components that can be reused across screens and future apps without rewriting any logic.
1. Star Rating Component
This lets users pick a rating from one to five and surfaces the chosen value so the host app can save it.
Custom Properties
| Name | Type | Direction | Purpose |
|---|---|---|---|
DefaultRating | Number | Input | Initial rating value (0‑5) |
SelectedRating | Number | Output | Exposes the currently selected rating |
OnRate | Behaviour | Input | Fires when the user clicks a star |
Implementation Steps
- Create a component and name it
StarRating. - Open the Properties pane and add the three custom properties above. Make sure Enhanced component properties is enabled in Settings → Upcoming features.
- Inside the component, add a vertical gallery bound to
[1,2,3,4,5]. Each item contains an icon or shape representing a star. - Set the gallery’s OnSelect to:
Set(compRating, ThisItem.Value); If( !IsBlank(compRating), /* trigger OutPut property and behaviour */ SetProperty(StarRating.SelectedRating, compRating); SetProperty(StarRating.OnRate, compRating); )
- The host app reads
StarRating1.SelectedRatingand can react toStarRating1.OnRate(e.g. write to a data source).
Usage in a Screen
Patch(CustomerFeedback, Defaults(CustomerFeedback), {
Rating: StarRating1.SelectedRating,
CustomerName: txtName.Text,
Comments: txtComments.Text,
CreatedDate: Now()
})2. Searchable Dropdown Component
A dropdown that filters itself as the user types – much friendlier than a long static picker.
Custom Properties
| Name | Type | Direction | Purpose |
|---|---|---|---|
Items | Table | Input | The full list of options |
DisplayField | Text | Input | Column name to show in the list |
SelectedItem | Record | Output | The record the user picked |
Placeholder | Text | Input | Hint text when nothing is selected |
Implementation Steps
- Add a control to a component called
SearchableDropdown. - Inside, place a Text input (the search box) and a List box (or gallery) that shows filtered results.
- Set the list’s Items property to:
Filter(SearchableDropdown.Items, SearchableDropdown.DisplayField = "ProductName", Text(SearchableDropdown.Items) & "" in SearchableDropdown.SearchText )
- When the user taps an item, store the record in a component‑level variable and fire an output behaviour property.
3. Status Badge Component
Displays a coloured label based on an order status. The colour mapping is defined once inside the component.
Custom Properties
| Name | Type | Direction | Purpose |
|---|---|---|---|
StatusValue | Text | Input | The status string to display (e.g. "Shipped") |
DisplayText | Text | Output | The formatted label |
BadgeColor | Colour | Output | The colour associated with the status |
Implementation Steps
- Add a Label control inside the component.
- Set the label’s Text property to
StatusBadge.StatusValue. - Set the label’s Fill to a Switch statement:
Switch(StatusBadge.StatusValue, "Pending", Color.Orange, "Shipped", Color.Green, "Delivered", Color.Blue, "Cancelled", Color.Red, Color.Gray )
- Optionally expose the colour as an output property so the host can use it elsewhere.
4. Confirmation Dialog Component
A pop‑up overlay that asks the user to confirm or cancel an action. The host app can show it conditionally and act on the result.
Custom Properties
| Name | Type | Direction | Purpose |
|---|---|---|---|
Title | Text | Input | Dialog heading |
Message | Text | Input | Body text |
ConfirmLabel | Text | Input | Text for the confirm button |
CancelLabel | Text | Input | Text for the cancel button |
OnConfirm | Behaviour | Input | Fires when user presses confirm |
OnCancel | Behaviour | Input | Fires when user presses cancel |
Visible | Boolean | Input | Toggles the dialog visibility |
Implementation Steps
- Create a component with a Group container. Inside, place two buttons and a label.
- Wire the Confirm button’s OnSelect:
SetProperty(ConfirmationDialog.OnConfirm, true); SetProperty(ConfirmationDialog.Visible, false)
- Wire the Cancel button similarly.
- The host can show the dialog by toggling a variable and handling the behaviour properties.
5. Paginated Table Component
Display a large collection one page at a time with previous/next buttons.
Custom Properties
| Name | Type | Direction | Purpose |
|---|---|---|---|
AllItems | Table | Input | Full dataset |
PageSize | Number | Input | Records per page |
CurrentPageItems | Table | Output | Slice of data for the current page |
CurrentPage | Number | Output | The active page number |
TotalPages | Number | Output | Calculated total pages |
Implementation Steps
- Inside the component, add a Data table or gallery.
- Add two Button controls (Previous, Next) and a Label for page info.
- Maintain a component‑level variable
_pageIndex. - Set the gallery’s Items to:
FirstN( LastN(PaginatedTable.AllItems, (PaginatedTable.TotalPages - PaginatedTable.CurrentPage + 1) * PaginatedTable.PageSize), PaginatedTable.PageSize )
-
Disable the Previous button when
_pageIndex = 1, and the Next button when_pageIndex = TotalPages. -
Expose
CurrentPage,TotalPages, andCurrentPageItemsas outputs so calling apps can synchronize scroll position or run custom logic.
Performance & Delegation
When you use a component, the data source is usually filtered before it reaches the component. For large datasets, push the filtering logic to the host app (e.g. use a delegated Filter on the source) and pass only the relevant subset into the component. This avoids bringing thousands of records into the component’s memory.
Common Pitfalls and Troubleshooting
| Pitfall | Solution |
|---|---|
| Forgetting to enable Enhanced component properties in app settings | Go to Settings > Upcoming features > Enable Enhanced component properties |
| Behaviour output properties don’t fire | Use SetProperty inside the component to trigger them; never call a behaviour property directly from the host—subscribe to it with an expression like OnConfirm = Set(confirmResult, true) |
| Components appear blank during preview | Ensure the component’s Visible property is true or bound to a variable that defaults to true |
| Changing a component in a library doesn’t update consuming apps | Publish the library, then open the consuming app – it will show a notification to refresh |
Wrapping Up
Building components is an investment that pays off every time you drop one onto a new screen or app. Start with small, focused components like the ones above, and soon you’ll have a personal toolbox that drastically cuts down development time. After perfecting them, export the components to a component library so you can share them across teams and maintain a single source of truth.
References
- Matthew Devaney – Learn Power Apps Canvas Components By Making 5 Components (original source for this article’s topic)
- Microsoft Learn – Work with canvas components
- Power Apps component library documentation
Learn how small coding practices—like using descriptive names, flattening conditions, and simplifying logic—can make your apps easier to update and less error-prone.
Move past the gallery and discover the hidden patterns for validation, navigation, and smart submission handling in your data entry forms.
PowerShell unlocks admin capabilities that the Power Platform admin center simply doesn’t offer—from recovering deleted apps to blocking trial licenses. Here’s how to wield them safely.