PowerApp

Introduction

In modern web and app development, interactivity is key to creating engaging user experiences. One common requirement is the ability to dynamically show or hide elements based on user actions. In this article, we'll explore how to achieve this functionality specifically for HTML text controls in Power Apps. By showing or hiding HTML text controls on button clicks, developers can enhance the user interface and create more dynamic applications.

Features

Benefits

Limitations

Step-by-Step Guide

  1. Open Power Apps.
    Create
  2. Click on the "Create" button.
    Blank App
  3. Click on "Blank app".
    Canvas
  4. Select "Blank tablet app" as we are creating an app for tablet devices.
     Tablet app
  5. Provide a name for your app.
  6. Select "Create" to proceed.
    Proceed
    HTML
  7. Add HTML Text control.
    Text Control
  8. Add some sample HTML into it.
    <table style='border: 1px solid black;'>
      <tr>
          <th style='background-color:grey'>Pro Number</th>
          <th style='background-color:grey'>Terms</th>
          <th style='background-color:grey'>Total A/R</th>
          <th style='background-color:grey'>Responsible Account</th>
          <th style='background-color:grey'>Responsible Customer</th>
          <th style='background-color:grey'>Responsible Name</th>
          <th style='background-color:grey'>Responsible Risk Code</th>
          <th style='background-color:grey'>Responsible Analyst</th>
      </tr>
      <tr>
        <td style='background-color: yellow;'>Cell 1</td>
        <td style='background-color: green; color: white;'>Cell 2</td>
        <td style='background-color: blue; color: white;'>Cell 3</td>
        <td style='background-color: red; color: white;'>Cell 4</td>
        <td style='background-color: blue; color: white;'>Cell 5</td>
        <td style='background-color: red; color: white;'>Cell 6</td>
        <td style='background-color: blue; color: white;'>Cell 7</td>
        <td style='background-color: red; color: white;'>Cell 8</td>
      </tr>
      <tr>
      </tr>
    </table>
    
    Show
  9. Add a button named "Show".
    Tree view
  10. Add a function on the "OnSelect" property of the "Show" button to set a variable to true.
  11. Set(VarShowHide, true);
    Hide
  12. Add another button named "Hide".
  13. Add a function on the "OnSelect" property of the "Hide" button to set the variable to false.
  14. Set(VarShowHide, false);
    VarShow
  15. Select the HTML text control and set its "Visible" property to the variable created in steps 10 and 12 , here it is “VarShowHide” but you can replace by your variable.
  16. Beautify your app by adding a header: Add a rectangle and set its background color. Then, add a text label and change its color to white for visibility on the background color.
    VIsible
    HTML Text

Conclusion

Dynamic control of HTML text visibility adds versatility to Power Apps development, allowing developers to create more engaging and user-friendly applications. By following the steps outlined above, developers can easily implement this functionality and enhance the interactivity of their apps. Whether it's revealing additional information or decluttering the interface, the ability to show or hide HTML text controls on button clicks empowers developers to create more dynamic and responsive applications.