Create a simple card (Preview)
[This article is pre-release documentation and is subject to change.]
This tutorial shows you how to create a card, ask a user for their name, and then show that name in the title of the card.
Prerequisites
- A Power Apps account.
- Familiarity with the Card Designer, variables, and Power Fx.
Create a card
Go to Power Apps and select Cards (preview) on the left.
Select + Create a card.
Enter "HelloWorldCard" under Card name and then select Create.
Ask for text input
Double-click on the Text label that has "Add and remove element to customize your new card.". Select the Remove button (X) at the top of the box to delete it.
Under the Insert menu, select Input. Then select Text input.
A new Text input box will appear on your card. This lets you gather text input from users who interact with the card.
With the Text input selected, edit the Label on the right by entering "What's your name?". This label will add text to the Text input box.
Assign variables
Under Name enter
UserAnswer. This is the name of the variable associated with the input the user enters.
Using a descriptive and unique variable name makes it easier to use in Power Fx expressions later in the card building process.
Now create another variable. This variable will be used to add the user's input (their name,
UserName) to the card title. Select Variables from the left pane and then select New variable.
Enter
UserNameunder Name. Leave the Type as Text and enterNo Nameas the Default value. Keep the Value Persistance set to Temporary. Then select Save.
Select the Text label at the top of the card. Replace the Text with
="Hello " & UserName.This will call the variable you just created in the title once the user has provided their name.
Use Power Fx in buttons
To say "Hello" to the name from user input, you need to create a button that uses Power Fx. Under the Display menu, select Button. The button will appear under the Text input box.
Under Title enter "Say Hello". You'll see the text on the button update as soon as you finish typing.
Select PowerFx under Type on the right. This moves your cursor up to the PowerFx bar at the top of the screen.
Enter the following Power Fx expression into the bar:
Set(UserName,UserAnswer)This assigns value of
UserAnswer, the user's input, to theUserNamevariable you put into the card title.
Test the card
Save the card by selecting the button on the top right. You should always save changes before playing an updated card. Then select Play.
Test your card and see how your input replaces the default value "No Name" in the card's title text. Note that if you replace the user input and select the button again the title text will change.
Next steps
Learn how to use more cards functionality in the simple shopping list tutorial.
Feedback
Submit and view feedback for