Dynamic UI Mastery: Showing/Hiding HTML Controls in Power Apps

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

  • Show or hide HTML text controls based on user actions.
  • Utilize buttons to trigger the visibility of HTML text controls.
  • Customize the appearance of the application with additional elements like headers and rectangles.
  • Enhance user experience by providing dynamic content visibility.

Benefits

  • Improved user experience: Users can interact with the application more intuitively by revealing or hiding specific information as needed.
  • Enhanced usability: By dynamically showing or hiding text controls, developers can optimize screen real estate and reduce clutter.
  • Increased flexibility: Developers have the flexibility to customize the visibility of HTML text controls based on specific user scenarios and requirements.

Limitations

  • Limited to Power Apps: This method is specific to Power Apps and may not be directly applicable to other development platforms.
  • Complexity: While the steps outlined below provide a straightforward process, more complex scenarios may require additional considerations and customizations.

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.


Similar Articles