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“.
To achieve this, follow the instructions below:
- Go to the App’s OnStart property and apply the code below:
OnStart = Set( varVisibleText, false )
varVisibleText = Specify a variable name
- Select the Button control (Click Me) and set its OnSelect property to a variable as:
OnSelect = Set( isVisible, true )
isVisible = Specify a Variable name
- Then, select the Text label control (Welcome to Power Apps !!) and set the created variable on its Visible property as:
Visible = !isVisible
isVisible = Created variable on Button’s OnSelect property
- 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.
- To work around this, select the Button control (Click to Get Job) and set its OnSelect property to a variable:
OnSelect = Set( buttonPressed, btnClick )
- buttonPressed = Specify a Variable name
- btnClick = Provide the Button name
- 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.
- 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.
- To do so, select the SAVE button and set its Visible property to the code below:
Visible = Len(txtEnterName.Text)
txtEnterName = Text input control name
- 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.
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:
- Power Apps Modern Information Button Control
- Power Apps Modern Link Control
- Power Apps Modern Badge Control
Preeti Sahu is an expert in Power Apps and has more than 6 years of experience working with SharePoint and the Power Platform. As a Power Platform expert for Power BI, Power Apps, Power Automate, Power Virtual Agents, and Power Pages, she is currently employed with TSinfo Technologies. She is the author of the book Microsoft Power Platform A Deep Dive. She also made a big technical contribution to SharePointDotNet.com in the form of articles on the Power Platform. She enjoys traveling and spending time with her family in her spare time.