How to Create a PowerApps Accordion in Simple Steps


Introduction

When you have a large amount of data or FAQs to show on a canvas PowerApps, you can make use of accordion. We know that accordions are useful when you want to toggle between hiding and showing a large amount of content. In this article, we will learn how to develop an accordion in PowerApps. Here we are using a SharePoint list to store our questions and answers for the FAQ. You can also use a local collection as per your requirement instead of a SharePoint list. Let's see step by step tutorial on how to create a FAQ accordion in PowerApps.

Step 1 - Create a SharePoint list

Here we have a simple list named PowerAppsAccordion with only two columns, Title, and Description. Add a few questions and answers to this list. Our list will look as below:

Accordion list

Step 2 - Add a flexible height gallery

Our questions and answers characters' lengths will be different so we cannot use the fixed height gallery. If different items in your data set contain different amounts of data in the same field, you can completely show items that contain more data without adding empty space after items that contain fewer data.

Add and configure a Flexible height gallery control so that you can:

  • Configure Label controls to expand or shrink based on their contents.
  • Position each control so that it automatically appears just under the control above it.

Flexible gallery

This flexible height gallery will have few default controls. Just select all and delete them.

Gallery

Set the data source of the gallery to our SharePoint list i.e. PowerAppsAccordion .

Step 3 - Add a button for the Question

Now to show the headings i.e. questions of the accordion, we will use button control. Set the properties of the button as below:
  • Border Radius = 0
  • Border = 0
  • Padding Left and Padding Right = 0
  • Text = ThisItem.Title

Accordion powerapps

Step 4 - Add label for the answers

Add a label and set the text property to ThisItem.Description. You can add more padding as shown in below screenshot to look it more better. 

Keeping Auto height On is the most important part of the step. This will help us to show flexible height as per the content of the answer.

Accordion in powerapps

Step 5 - Show Hide Logic

Now we need to show and hide the answer label based on the user selection. Simply put the below formula as a visible property of your label.

If(Gallery3.Selected.ID = ThisItem.ID, true, false)

Step 6 - Add Icon to show the up and down arrow

Add Icon and set the Icon property as below:

If(Gallery3.Selected.ID = ThisItem.ID, Icon.ChevronDown, Icon.ChevronUp)

Accordion in powerapps

Output:

Powerapps accordion

I hope you have liked this article for FAQ in PowerApps. If you have any questions, feel free to ask in the comment section below. Thanks for reading.

P.S – This article was originally published at this link .

Post a Comment

0 Comments