How To Create A Beautiful Accordion In PowerApps

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:

How to Create a Beautiful Accordion in PowerApps

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.

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

How to Create a Beautiful Accordion in PowerApps

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

How to Create a Beautiful Accordion in 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.

How to Create a Beautiful 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 propety 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)

How to Create a Beautiful Accordion in PowerApps

Final Output

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.


Similar Articles