top of page

Customizing SharePoint Framework Web Part Properties - Part Four


In this article, you will learn how to add the dropdown fields to SharePoint Framework Web part properties pane. In my previous articles, I have introduced the custom properties, explained check box field properties sample and managing multiple pages on properties pane of SharePoint Framework (SPFx) Web part.

In my SPFx article series, you can learn about SPFx introduction, prerequisites, steps for setting up the environment, developing and testing the Web parts, using the local environments.

In the previous article sample, you will have seen adding the multiple pages to the properties pane of SPFx Web part. You can use the samples from the previous articles to accomplish the task. In this article, you will see populating the dropdown options on the SPFx Web part properties pane. First, let us bind the list names to the dropdown property. Subsequently, the list items can be loaded on the Web part, which is based on the list name selected on the dropdown field. As you have noticed in the previous articles, the property pane has pages, each page has a group and group can contain multiple properties.

DropDown property 

The dropdown property is defined, using PropertyPaneDropdown method. It contains the following.

  • property name- Custom name to the property, which can be used as a variable.

  • label- The text to be displayed for the drop down.

  • isDisabled- Boolean value to identify whether the property is enabled or disabled.options- The dropdown values with the key, text, index and isSelected (boolean to identify whether the option is selected) properties.

The snippet given below shows the basic definition of dropdown field.

  1. PropertyPaneDropdown('propertyname',{    

  2. label: "label",    options:[       

  3. {key:"key1",text:"value1",isSelected:true},       

  4. {key:"key2",text:"value2"}  

  5. })  


In this sample, you will see a single page with one group, the group name and a field (dropdown property). The code snippet given below shows the get property settings method (propertyPaneSettings). You can see the list names, which are bound to the dropdown options.

  1. protected get propertyPaneSettings(): IPropertyPaneSettings {  

  2. return {      

  3. pages: [        {          

  4. header: {            

  5. description: strings.PropertyPaneDescription,          

  6. },          

  7. groups: [            {              

  8. groupName:"Lists",              

  9. groupFields:[                

  10. PropertyPaneDropdown('DropDownProp',{                

  11. label: "Select List To Display on the page",                

  12. options:[                  

  13. {key:"TestList",text:"TestList"},                  

  14. {key:"Documents",text:"Documents"}]                

  15. })              

  16. ]            

  17. }          

  18. ]        

  19. }      

  20. ]    

  21. };  

  22. }  

The dropdown value can be identified, using the property name with the help of properties identifier (


The custom functions are then written to pull the information, which is based on the selected dropdown value. The custom functions explained in the previous articles are used here to pull the data.

The snapshot given below shows the page with the Web part property pane, which shows the dropdown field with the option.


Thus, you have learned adding dropdown field to SharePoint Framework Web part properties pane.

What Next

In my next article, you will learn how to dynamically bind the values to dropdown field with the full code example and screenshots.



bottom of page