npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sadhus/react-people-picker

v1.0.8

Published

A React People Picker component mimicking Outlook's user search UI with deletable chips and debounced search.

Readme

React People Picker

A versatile and customizable React People Picker component built with Material-UI, featuring search, debounce, and multi-selection capabilities.

✨ Features

  • Material-UI Integration: Seamlessly integrates with your Material-UI themed applications.
  • Search Functionality: Filter available options by typing in the input field.
  • Debounced Search: Optimizes performance by delaying search queries, reducing unnecessary API calls or list filtering.
  • Customizable Options: Easily provide your own list of people.
  • Controlled Component: Manage selected values from parent component state.
  • Clear Selection: Option to clear all selected items.

Screenshots

search/results users/tooltip validation

🚀 Installation

First, install the package in your React project:

npm install @sadhus/react-people-picker
  or
yarn add @sadhus/react-people-picker

This component relies on react, react-dom, @mui/material, @mui/icons-material, @emotion/react, and @emotion/styled as peer dependencies. Ensure these are also installed in your project:

npm install react react-dom @mui/material @mui/icons-material @emotion/react @emotion/styled
  or
yarn add react react-dom @mui/material @mui/icons-material @emotion/react @emotion/styled

💡 Usage

import React, { useState } from 'react';
import { Box, Button } from '@mui/material';
import PeoplePicker from "@sadhus/react-people-picker";


// Mock API call in the CONSUMING APPLICATION
const mockUsersApiCall = (searchTerm) => {
  console.log('Consumer App: API Call for search:', searchTerm);
  const allUsers = [
    { id: '1', name: 'Alice Smith', email: '[email protected]', alias: 'alismi' },
    { id: '2', name: 'Bob Johnson', email: '[email protected]', alias: 'bobjoh' },
    { id: '3', name: 'Charlie Brown', email: '[email protected]', alias: 'chabro' },
    { id: '4', name: 'Diana Prince', email: '[email protected]', alias: 'diapri' },
    { id: '5', name: 'Eve Adams', email: '[email protected]', alias: 'evedam' },
  ];

  return new Promise((resolve) => {
    setTimeout(() => {
      const lowercasedQuery = searchTerm.toLowerCase();
      const filtered = allUsers.filter(user =>
        user.name.toLowerCase().includes(lowercasedQuery) ||
        user.email.toLowerCase().includes(lowercasedQuery) ||
        (user.alias && user.alias.toLowerCase().includes(lowercasedQuery)) 
      );
      resolve(filtered);
    }, 300);
  });
};


function App() {
  const [selectedUsers, setSelectedUsers] = useState([]);
  const [formSubmitted, setFormSubmitted] = useState(false);

const handleSubmit = () => {
    setFormSubmitted(true); // Trigger validation
    
    // do respective form submission logic here
  };

  return (
    <div className="App">
      <PeoplePicker
        maxWidth="400px"
        autocompleteBordercolor="dimgray"
        chipColor="dimgray"
        tooltipColor="darkgray"
        placeholder="Search user by name/email/alias"
        debounceDelay={300}
        minSearchLength={3}
        initialSelectedUsers={[]}
        onSearch={mockUsersApiCall}
        onSelectedUsersChange={setSelectedUsers}
        isRequired={true}
        requiredErrorMessage="At least one user is required"
        isError={formSubmitted && selectedUsers.length === 0}
      />

      <Box sx={{ display: "flex", justifyContent: "center", mt: 2 }}>
        <Button
          variant="contained"
          onClick={handleSubmit}
          size="small"
          sx={{ backgroundColor: "black", color: "white" }}
        >
          submit
        </Button>
      </Box>
    </div>
  );
}

export default App;

⚙️ Props

| Prop Name | Type | Default | Description | | :------------ | :----------- | :-------------------------------- | :------------------------------------------- | | initialSelectedUsers | Array<{id: string, name: string, email?: string}> | [] | An array of initial selected people objects. Each object should at least have id and name. | | onSearch | (searchTerm: string) => Promise<Array<{id: string, name: string, email?: string}>> | undefined | A function that receives the search term and should return a Promise resolving to an array of people objects. This is where your API call or data filtering logic goes. | | onSelectedUsersChange | (selected: Array<{id: string, name: string, email?: string}>) => void | undefined | Callback function triggered when the selection changes, receiving the updated array of selected people. | | debounceDelay | number | 300 | The time in milliseconds to debounce the onSearch function calls. | | minSearchLength | number | 3 | Minumum character length needed for a search to trigger. | | maxWidth | number | 600px | Maximum width of the control. | | autocompleteBordercolor | string | theme.palette.primary.dark | border color of the autocomplete control. | | chipColor | string | theme.palette.primary.dark | fill color of the chip holding the user name in the autocomplete control. | | tooltipColor | string | theme.palette.primary.light | color of the tooltip when the cursor is hovered on the chip. | | placeholder | string | 'Search User' | The placeholder text for the input field. | | isRequired | boolean | false | If the control mandatory in the form. | | requiredErrorMessage | string | null | This field is mandatory when isRequired field is part of the control. |

🛠️ Development

To set up the development environment for this component library:

  1. Clone the repository:
git clone [https://github.com/adityasrk/react-people-picker.git](https://github.com/adityasrk/react-people-picker.git)
cd my-people-picker-library
  1. Install dependencies:
npm install or yarn install
  1. Run the Rollup build in watch mode (optional, for library development):
npm run dev

This will recompile your library files (dist/) automatically on changes.

  1. Run the demo application:

In a separate terminal, navigate to the demo-app directory and start the CRA development server:

cd demo-app
npm install # Only if not done during the main 'npm install' or 'yarn install' at root
npm start

This will open the demo application in your browser, where you can test the PeoplePicker component.

Color Reference

| Color | Hex | | :------------ | :--------- | | theme.palette.primary.dark | #1565c0 | | theme.palette.primary.light | #42a5f5 | | dimgray | #696969 | | darkgray | #A9A9A9 |

🤝 Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.