Use Panels to Group Related Questions

Edit in →
Survey Creator

If your survey or form contains related questions, you can organize them in groups to give respondents context and help them better understand the purpose of each question. A survey element that groups other survey elements on a page is Panel. This demo shows how to create and configure panels.

Create a Panel

To add a panel to your survey or form, define an object with the type property set to "panel" and add it to the elements array. Within this object, specify the panel's title and a unique name that identifies the panel. Optionally, you can specify a description to place under the title.

To add questions to a panel, declare a nested elements array and populate it with question configurations. Since panels can be nested one into another, the elements array can also contain configurations of other panels.

Expand and Collapse Panels

Panels can be expanded and collapsed in code or in the UI. When collapsed, a panel displays only its title and description. To expand or collapse a panel, users should click its title. This feature helps you optimize screen space when your survey contains many questions.

To expand or collapse a panel, call its expand() or collapse() method. To find out the current state of a panel and decide which method to call, use the isExpanded and isCollapsed properties. Alternatively, you can call the toggleState() method to toggle a panel's expand state. All these methods and properties belong to a PanelModel object instance. To access it, use SurveyModel's getPanelByName() method:

import { Model } from "survey-core";

const surveyJson = {
  // ... 
  "elements": [{
    "type": "panel",
    "name": "myPanel",
    "elements": [ ... ]
  }]
};
const survey = new Model(surveyJson);
// Access a panel with a specified name
const myPanel = survey.getPanelByName("myPanel");
// Call `toggleState()` or any other `PanelModel` method
myPanel.toggleState();

To allow users to expand and collapse a panel, set its state property to "expanded" or "collapsed", depending on the initial state you want. In this demo, you can expand and collapse both panels.

Your cookie settings

We use cookies on our site to make your browsing experience more convenient and personal. In some cases, they are essential to making the site work properly. By clicking "Accept All", you consent to the use of all cookies in accordance with our Terms of Use & Privacy Statement. However, you may visit "Cookie settings" to provide a controlled consent.

Your renewal subscription expires soon.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.

Your renewal subscription has expired.

Since the license is perpetual, you will still have permanent access to the product versions released within the first 12 month of the original purchase date.

If you wish to continue receiving technical support from our Help Desk specialists and maintain access to the latest product updates, make sure to renew your subscription by clicking the "Renew" button below.