The Card Component lets you display a repeating layout for each item in an array from a data set. You define the layout once, and it’s automatically applied to every item in the list. This is useful for displaying things like records, profiles, or summaries in a consistent format.
Each card uses the same layout template and is bound to its own item in the array. You can’t directly access other items in the array or the full array from inside an individual card.
Appearance Settings
The Card Component includes standard appearance settings, such as size and position, background, text, padding (for details on standard appearance settings, check the Altering the Appearance of an App Studio Component article) and specific styling options: Component layout, Card appearance, and Card layout.
- Use Component layout to arrange the cards within the Component.
- Use Card appearance options to customize size, text, and other appearance settings of the card.
- Use Card layout to arrange the inner Components displayed in each Card.
Configuration Settings
The following settings are available in the Configuration tab for the Card Component:
Setting | Description |
---|---|
Data set | Select the data set that provides the array of items to render as cards. |
Data path | Specify the path to the array of objects within the selected data set. |
Tooltip text | Provide information that appears when users hover over the Component. |
Example: Displaying a List of Users with the Card Component
In this example, we will show how to use the Card Component to display a list of user profiles. You will need to provide the user records, which you can do by connecting to an external API or by creating a data table manually within App Studio. Each card will present the user’s first name, last name, and avatar image.
Step 1: Add a Data set
Prepare a Data set. Use a data source containing user records with fields like firstName, lastName, and image.
Step 2: Add the Card Component
- In the Components panel, go to Data > Card.
- Drag the Card Component onto the canvas.
- In the Configuration tab, set:
Data set: Select your user data source.
Data path: Provide the path to the array of users. - (Optional but recommended) Rename your Card component for easier referencing, for example, Card-Users instead of Card-0-46-0.
Step 3: Add components inside the card
- Select the Card Component on the canvas.
- Drag a Text Component inside the Card layout.
- In the Configuration > Text field, enter:
{{<Card component ID> card data.firstName}} {{<Card component ID> card data.lastName}}
<Card component ID> is a data set created by the App Studio. Replace <Card component ID> with the actual data set name generated for the card (for example, Card-0-46-0, Card-Users). - Drag an Image Component into the Card.
- Set the Data set for the Image Component to match the Card's data set: <Card component ID> card data.
- For the Data source, select the appropriate field.
Step 4: Preview the App
Preview the App to see the result. The Card Component will render one card per user, showing the user's full name and avatar.
Example: Taking Actions on Cards
In this example, we build on the previous setup from Example: Displaying a List of Users with the Card Component . Each card will include a Select button that allows users to choose a person. When you click the Select button, a detail view populates with the user's information.
Step 1: Reuse the Card Component
Continue using the Card Component set up in the first example. It should already display a list of users, each showing a name and avatar.
Step 2: Create an App variable to store the selected user
- Go to App > Configuration > Data sets.
- Click Add data set and configure it as follows:
Setting Description Name
selectedUser
Type
Variable
Expression
Leave empty
This variable will hold the data of the user selected via the button.
Step 3: Create an Action Sequence to set selectedUser
- Go to the Action Sequences tab (
).
- Create a new action sequence with the following settings:
- Name of the Action Sequence: SelectUser.
- Input variables: Add a variable called cardData.
- Actions: Add a new Action with the following parameters:
Setting Description Action
Set a variable
Variable to set
selectedUser
Value to set
{{{cardData}}}
Note: Triple braces ({{{...}}}) are required to pass the full object correctly.
Step 4: Add a Select button
- Inside the Card layout, add a User interaction > Button Component.
- Set the Text property to: Select.
- Scroll to Event handlers and click New event handler.
- Configure the event:
Setting Description Handler name
View details
Event type
Click
Action
Call an action sequence
Action sequence to call
Set a variable
cardData
{{{Card-XXX card data}}}
Replace Card-XXX with the actual Card component ID shown in your App (e.g., Card-0-46-0, Card-Users).
Step 5: Wrap selectedUser with a JavaScript Data set
The selectedUser variable needs to be wrapped in a JavaScript data set to make the data available to components like Form.
- Go to App > Configuration > Data sets.
- Click Add data set with the following settings:
Setting Description Name
selectedUserJS
Type
Javascript
Inputs
Data set: selectedUser
Required: enabled
Output
Output data type: Object
Add the fields you want to be displayed in details, for example:
firstNamelastName
email
You can include additional fields as needed to be displayed in the user’s detail view.Code
return inputs.selectedUser;
Step 6: Add a detail view to display the selected user
- In Components > Data, drag a Form Component onto the canvas. Make sure this Form is outside of the Card Component.
- Configure the form:
Setting Description Read only
Enabled
Data set
selectedUserJS
Fields
Adjust the field settings per your requirements.
Step 7: Preview the App
Preview the App to see the result. The Card Component should display the list of users. When you click Select on a card, the Form updates with that user's details. The example below displays First Name, Last Name, Username, Date of Birth, and Email of the user.
Example: Using Cards in Image Fetching
For another example of using the Card Component, see the Configuring Image Fetching article.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article