Overview
Many times, the SharePoint web part needs to show information from the SharePoint site. One good example of it is to show SharePoint lists on the site. PnP (Patterns and Practices) offers ListPicker control which allows selecting one or multiple available lists/libraries from the current SharePoint site.
In this article, we will explore the ListPicker control from PnP on how to use and configure it in the SPFx web part. We will develop a practical scenario to integrate ListPicker control in the SPFx web part.
Develop SharePoint Framework web part
Open a command prompt. Create a directory for the SPFx solution.
md spfx-pnp-listpicker
Navigate to the above-created directory.
cd spfx-pnp-listpicker
Run the Yeoman SharePoint Generator to create the solution.
yo @microsoft/sharepoint
The Yeoman generator will present you with the wizard by asking questions about the solution to be created.

- Solution name: Hit enter to have the default name (spfx-pnp-listpicker in this case) or type in any other name for your solution.
- Selected choice: Hit enter
- The target for the component: Here we can select the target environment where we are planning to deploy the client web part i.e. SharePoint Online or SharePoint On-Premises (SharePoint 2016 onwards).
- Selected choice: SharePoint Online only (latest)
- Place of files: We may choose to use the same folder or create a sub-folder for our solution.
- Selected choice: Same folder
- Deployment option: Selecting Y will allow the app to be deployed instantly to all sites and will be accessible everywhere.
- Selected choice: N (install on each site explicitly)
- Permissions to access web APIs: Choose if the components in the solution require permission to access web APIs that are unique and not shared with other components in the tenant.
- Selected choice: N (solution contains unique permissions)
- Type of client-side component to create: We can choose to create a client-side web part or an extension. Choose the web part option.
- Selected choice: WebPart
- Web part name: Hit enter to select the default name or type in any other name.
- Selected choice: PnPListPicker
- Web part description: Hit enter to select the default description or type in any other value.
- Selected choice: Use PnP LiskPicker control in SPFx solution
- Framework to use: Select any JavaScript framework to develop the component. Available choices are (No JavaScript Framework, React, and Knockout)
- Selected choice: React
The Yeoman generator will perform the scaffolding process to generate the solution. The scaffolding process will take a significant amount of time.
Once the scaffolding process is completed, lock down the version of the project dependencies by running the below command.
npm shrinkwrap
In the command prompt type the below command to open the solution in the code editor of your choice.
code
NPM packages dependency
@pnp/spfx-controls-react (https://sharepoint.github.io/sp-dev-fx-controls-react/)
SharePoint Framework React controls is an open-source library that offers a reusable set of React controls to be used in the SPFx solution.
On the command prompt, run the below command to include the npm package.


Join the conversation! Your thoughts help the community grow.