<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Canvas PowerApps - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Canvas PowerApps - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sat, 23 May 2026 22:20:40 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/canvas-powerapps/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Extend Power Apps with Reusable Components ]]>
                </title>
                <description>
                    <![CDATA[ If you have experience in traditional software development, low-code tools may feel a bit sparse at first. But to many people’s surprise, traditional techniques often translate quite well to low-code  ]]>
                </description>
                <link>https://www.freecodecamp.org/news/powerapps-component-crash-course/</link>
                <guid isPermaLink="false">682779afad5694b25984f6b1</guid>
                
                    <category>
                        <![CDATA[ Canvas PowerApps ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Low Code ]]>
                    </category>
                
                    <category>
                        <![CDATA[ components ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Brandon Wozniewicz ]]>
                </dc:creator>
                <pubDate>Fri, 16 May 2025 17:45:19 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1747410099474/8471a651-503f-4ced-a172-7dadac930039.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you have experience in traditional software development, low-code tools may feel a bit sparse at first. But to many people’s surprise, traditional techniques often translate quite well to low-code development. Not always one-for-one – but usually close enough.</p>
<p>One of the most fundamental tasks when building an application is breaking it down into its core parts, or components. Websites are constructed from smaller building blocks. Just how small? Well, that’s up to you, the developer.</p>
<p>In the example below, we can spot some obvious elements: a header, a search box, perhaps a sidebar for navigation, and a main content area. Applications emerge from many smaller parts coming together.</p>
<img src="https://www.scriptedbytes.com/content/images/2025/05/components.png" alt="Image of components of a website" width="600" height="400" loading="lazy">

<p>Components allow us to isolate responsibility and manage complexity for specific parts of an application. In both traditional and low-code development, they play a vital role in creating maintainable, reusable, and testable products.</p>
<p>In this article, you’ll learn what a component is. Then we’ll build a custom text field component inside a Canvas app.</p>
<h3 id="heading-prerequisites">Prerequisites</h3>
<p>This tutorial assumes a basic understanding of Microsoft Power Apps. While not required to understand the article, to actively follow along, you’ll need access to a Power Platform environment with the App Maker security role.</p>
<h3 id="heading-table-of-contents">Table of Contents</h3>
<ul>
<li><p><a href="#heading-the-concept-of-a-component">The Concept of a Component</a></p>
</li>
<li><p><a href="#heading-how-to-build-your-own-component">How to Build Your Own Component</a></p>
</li>
<li><p><a href="#heading-wrapping-up">Wrapping Up</a></p>
</li>
</ul>
<h2 id="heading-the-concept-of-a-component">The Concept of a Component</h2>
<p>The idea of components isn’t new – and it’s not exclusive to software.</p>
<p>Let’s think about a car for a moment. A car is made up of many smaller parts: wheels, an engine, seats, a steering wheel, and so on. But it’s the concept of the car – and specifically its ability to transport us – that provides value. That concept emerges from the way the individual parts work together.</p>
<p>Now imagine you get a flat tire. Not a good day. But thanks to how cars are designed, you don’t need a whole new car – maybe not even a new tire. You fix the issue and you’re back on the road within a few hours. Breaking things into smaller parts helps make the whole system more resilient. Applying this same principle to application development is a smart, future-proof approach.</p>
<h3 id="heading-two-broad-types-of-components">Two Broad Types of Components</h3>
<p>Within an application, components can vary in complexity and responsibility. Some are simple, like a text label. Others are more complex, like a pop-up dialog. Regardless of their complexity (again, your design choice), components typically fall into one of two categories:</p>
<ul>
<li><p><strong>Presentational ("Dumb") Components</strong></p>
</li>
<li><p><strong>Container ("Smart") Components</strong></p>
</li>
</ul>
<p>The difference comes down to purpose. A container component may interact with external sources and usually mutates state. A presentational component, on the other hand, is generally only responsible for how things look and light communication with the application.</p>
<p>Container components are often more complex and harder to test. Presentational components are typically simpler and more predictable.</p>
<p>This isn’t to say you should avoid container components. That’s not realistic. At some point, your app will need to talk to the outside world.</p>
<h3 id="heading-aside-pure-functions">Aside: Pure Functions</h3>
<p>The concept of <strong>pure functions</strong> is useful here.</p>
<p>A function is considered <em>pure</em> if it always returns the same output for the same input and doesn’t interact with any external state.</p>
<pre><code class="language-JavaScript">// Example 1 (pure)
function add(x, y) {
  return x + y;
}

console.log(add(2, 3)); // Always 5

// Example 2 (not pure)
function subtract(x) {
  const y = Math.floor(Math.random() * 100) + 1; // Random number between 1 - 100
  console.log(y);
  return x + y;
}

console.log(subtract(5)); // Unpredictable
</code></pre>
<p>Just like <code>add()</code> is pure and <code>subtract()</code> is not, a presentational component behaves like a pure function: same input, same output. The output might be how the UI appears or an event with associated data.</p>
<h3 id="heading-more-about-inputs-and-outputs">More About Inputs and Outputs</h3>
<p>If you’ve built a Canvas App before, you’ve already used components – even if you didn’t realize it. Most controls in a Canvas App are presentational components.</p>
<p>Take the <strong>Label</strong> control. It receives an input (<code>Text</code>) and renders output (the text on screen).</p>
<img src="https://www.scriptedbytes.com/content/images/2025/05/Snag_37f5d6fa.png" alt="Image of Canvas App label" width="600" height="400" loading="lazy">

<p>Events are another kind of output. For example, the <strong>Button</strong> control emits an event when clicked – handled through the <code>OnSelect</code> property. That property allows the app to respond to the click and perform some logic.</p>
<img src="https://www.scriptedbytes.com/content/images/2025/05/Snag_37fa1150.png" alt="Image of Canvas app button" width="600" height="400" loading="lazy">

<p>💡 When a component sends a message back to the application the component is said to have <em>emitted an event.</em></p>
<p>Now let’s look at the <strong>Text Input</strong> control.</p>
<p>Like the others, it has inputs (like <code>Placeholder</code>). But it also emits a <code>Change</code> event via <code>OnChange</code>. Even better, it passes data back to the application through its <code>Value</code> property. As the user types, the value updates. That value is how we access what they typed.</p>
<img src="https://www.scriptedbytes.com/content/images/2025/05/Snag_38070a2d.png" alt="Image of Canvas app text input" width="600" height="400" loading="lazy">

<h2 id="heading-how-to-build-your-own-component">How to Build Your Own Component</h2>
<p>Let’s build a simple, customized input component. It will include:</p>
<ul>
<li><p>A label above the input</p>
</li>
<li><p>Optional “required” validation</p>
</li>
<li><p>Change detection and data output</p>
</li>
</ul>
<p>Here is what it will look like:</p>
<img src="https://www.scriptedbytes.com/content/images/2025/05/image.png" alt="Image of custom text field to be built" style="display:block;margin:0 auto" width="600" height="400" loading="lazy">

<h3 id="heading-part-1-create-the-component">Part 1: Create the Component</h3>
<ol>
<li><p>Navigate to the <strong>Components</strong> section of your Canvas App.</p>
</li>
<li><p>Add a new component and name it <code>cmp_baseInput</code>.</p>
</li>
<li><p>Resize it to 340 (w) x 100 (h).</p>
</li>
</ol>
<img src="https://www.scriptedbytes.com/content/images/2025/05/Snag_3819d94d.png" alt="Image of how to create a component" width="600" height="400" loading="lazy">

<h3 id="heading-part-2-add-controls">Part 2: Add Controls</h3>
<ol>
<li><p>Add a <strong>Text Input</strong> control, centered.</p>
</li>
<li><p>Add two <strong>Labels</strong>—one above, one below the input.</p>
</li>
<li><p>Rename them:</p>
<ul>
<li><p><code>lbl_label</code></p>
</li>
<li><p><code>lbl_hint</code></p>
</li>
<li><p><code>txt_textField</code></p>
</li>
</ul>
</li>
</ol>
<img src="https://www.scriptedbytes.com/content/images/2025/05/Snag_381d4ce8.png" alt="Image of the appropriate controls added to the component" width="600" height="400" loading="lazy">

<h3 id="heading-part-3-add-custom-properties">Part 3: Add Custom Properties</h3>
<p>Add four properties to the component. We're primarily concerned with the Property Type, Property Definition, and Data Type properties.</p>
<ul>
<li><p><code>IsRequired</code> (Data, Input, Boolean)</p>
</li>
<li><p><code>Label</code> (Data, Input, Text)</p>
</li>
<li><p><code>Value</code> (Data, Output, Text)</p>
</li>
<li><p><code>OnChange</code> (Event)</p>
</li>
</ul>
<img src="https://www.scriptedbytes.com/content/images/2025/05/Snag_38262956.png" alt="Image of custom properties added to the component" width="600" height="400" loading="lazy">

<h3 id="heading-part-4-connect-the-properties">Part 4: Connect the Properties</h3>
<p>Set the control's properties as follows.</p>
<pre><code class="language-plaintext">lbl_label.Text = cmp_baseInput.Label

lbl_hint.Text = "This field is required."
lbl_hint.Visible = cmp_baseInput.IsRequired And Len(txt_textField.Value) &lt; 1

txt_textField.OnChange = cmp_baseInput.OnChange()

cmp_baseInput.Value = txt_textField.Value
cmp_baseInput.Label = "Placeholder Label"
</code></pre>
<h3 id="heading-part-5-style-it">Part 5: Style It</h3>
<pre><code class="language-plaintext">lbl_label.Size = 12
lbl_label.Height = 24
lbl_label.FontColor = RGBA(122, 138, 143, 1)

lbl_hint.Size = 10
lbl_hint.Height = 24
lbl_hint.FontColor = RGBA(215, 58, 60, 1)
lbl_hint.FontWeight = 'TextCanvas.Weight'.Semibold
</code></pre>
<h3 id="heading-part-6-add-it-to-the-app">Part 6: Add It to the App</h3>
<ol>
<li><p>Go back to the application screen.</p>
</li>
<li><p>Insert the component and name it <code>cmp_userName</code>.</p>
</li>
<li><p>Add a label nearby and set its text to:<br><code>"The user name is: " &amp; cmp_userName.Value</code></p>
</li>
</ol>
<img src="https://www.scriptedbytes.com/content/images/2025/05/Snag_3835242d.png" alt="Image of inserting the component in the application" width="600" height="400" loading="lazy">

<img src="https://www.scriptedbytes.com/content/images/2025/05/Snag_383a4039.png" alt="Image of the component inserted into the application" width="600" height="400" loading="lazy">

<h3 id="heading-part-7-test-it">Part 7: Test It</h3>
<ul>
<li><p>Type in the component and click outside of it → label near the component updates and the hint disappears.</p>
</li>
<li><p>Clear the text → hint reappears</p>
</li>
<li><p>Set <code>IsRequired</code> to false → hint disappears</p>
</li>
<li><p>Set <code>OnChange</code> to <code>Notify("A change occurred!")</code> and type in the input→ a toast message appears with you notification.</p>
</li>
</ul>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>You’ve just created a functional, presentational component. It handles labels, validation, value output, and even events – all in one package.</p>
<p>This is the real power of components: abstraction, clarity, and reusability. Whether you're in a traditional or low-code environment, thinking in components helps you break complexity into manageable parts.</p>
<p>As your apps grow, this mindset will pay off. You'll spend less time rewriting logic and more time building value – one well-defined part at a time.</p>
<p>Found this helpful? I write about practical automation, productivity systems, and building smarter workflows — without the jargon. Visit me at <a href="http://brandonwoz.com">brandonwoz.com</a>.</p>
<p><em>Stay curious and keep building.</em></p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
