Show or Hide Label Control On Button Click in Power Apps

In this Power Apps beginners tutorial, I will explain to you, how to show or hide label control on button click in Power Apps.

Additionally, we will explore how to work with the Show Hide Power Apps Button based on a Text Input’s length of its Value.

Hide Label Control On Button Click in Power Apps

In this example, we will discuss how to hide a label control when a button is clicked in Power Apps.

  • The screenshot below represents a Power Apps Text Label control (Welcome to Power Apps !!) and a Button control (Click Me).
  • In Power Apps, the label control will disappear when the user clicks the button named “Click Me“.
Hide Power Apps Label Control On Button Click

To achieve this, follow the instructions below:

Step-1:

  • Go to the App’s OnStart property and apply the code below:
OnStart = Set(
    varVisibleText,
    false
)

Where,

varVisibleText = Specify a variable name

How to Hide Power Apps Label Control On Button Click
How to Hide Power Apps Label Control On Button Click

Step-2:

  • Select the Button control (Click Me) and set its OnSelect property to a variable as:
OnSelect = Set(
    isVisible,
    true
)

Where,

isVisible = Specify a Variable name

Show Hide Power Apps Label Control with Button Click
Show Hide Power Apps Label Control with Button Click

Step-3:

  • Then, select the Text label control (Welcome to Power Apps !!) and set the created variable on its Visible property as:
Visible = !isVisible

Where,

isVisible = Created variable on Button’s OnSelect property

Show Hide Power Apps Label Control on Button Click
Show Hide Power Apps Label Control on Button Click
  • Save, publish, and close the app to finish. Restart the app, then click the Click Me button. Clearly, the label will go or hide from the screen.

This is how to hide a Label control on Button click in Power Apps.

Show Power Apps Label Control On Button Click

  • Next, we’ll look at another example that how we can show Power Apps Label control with a Button on Click.
  • As you can see, there is a Power Apps Button (Click to Get Job). The text label will appear as seen in the screenshot below when a user clicks on this button.
Show label control on button click Power Apps
Show label control on button click Power Apps
  • To work around this, select the Button control (Click to Get Job) and set its OnSelect property to a variable:
OnSelect = Set(
    buttonPressed,
    btnClick
)

Where,

  1. buttonPressed = Specify a Variable name
  2. btnClick = Provide the Button name
PowerApps set variable on button click
PowerApps set variable on button click
  • Next, select the Label control and apply the code below on its Visible property:
Visible = If(
    buttonPressed = btnClick,
    true,
    false
)

Refer to the screenshot below.

How to Show Power Apps Label Control On Button Click
How to Show Power Apps Label Control On Button Click
  • Save, Publish, and Close the app to finish. Restart the app, then click the Click to Get Job button. You can able to view the text label message.

This is how to show or hide a label control in Power Apps on a button click.

Show Hide Power Apps Button based on a Text Input’s length of its Value

  • In this case, I would like to hide a button unless a particular Text Input has a value of at least one character.
    • If the Text input control has no value, the Button (SAVE) will be hidden.
    • If the Text input control value is at least one character, the Button (SAVE) will be displayed.
Hide label control on button click PowerApps
Hide label control on button click PowerApps
  • To do so, select the SAVE button and set its Visible property to the code below:
Visible = Len(txtEnterName.Text)

Where,

txtEnterName = Text input control name

Hide label on button click Power Apps
Hide label on button click Power Apps
  • Save, Publish, and Close the app. Restart the app once again. There won’t be any buttons visible on the screen. Simply type any letter into the text input field to make the SAVE button appear.

This is how to work with the Show or Hide Power Apps Button based on a Text Input’s length of its Value.

Conclusion

I hope you now have an idea of how to show or hide a label control on a button click in Power Apps.

You may also like the following Power Apps tutorials: