People picker
Picks people by name, with their faces and roles, the ones picked lately first, and search as you type.
Installation
npm i @uisatin/ui @uisatin/proimport '@uisatin/ui/styles.css'
import '@uisatin/pro/styles.css'
import { PeoplePicker, type PeopleGroup, type Person } from '@uisatin/pro/people-picker'Part of Satin Pro, the licensed edition: @uisatin/pro on top of @uisatin/ui at the same version, its stylesheet after Free's. Satin Pro isn't on npm yet.
About 2.4 kB of JavaScript, minified and gzipped, on top of the @uisatin/uicomponents it uses (React aside).
First time with Satin? Set it up once, styles and fonts included, with the installation guide.
API Reference
The PeoplePicker component (Satin Pro, @uisatin/pro/people-picker) is a Combobox for people: rows show an avatar, the name and the role (or email), picks show as chips with avatars. Each person is { id, name, role, email, avatar, tone, disabled }; avatar is an image URL, and without one the initials show on the tone. People come from people, titled groups ({ label, people }[]), or search(query, { signal }), called searchDelay ms after the last keystroke and at once with '' on open; a newer query aborts the older one, and meanwhile the last results stay, narrowed by the query. people and groups filter as you type, with no delay. recent is listed first while the query is empty. value holds the people, not their ids. Every other Combobox prop (label, hint, error, footer, size, open state) works as there.
| Prop | Type | Default |
|---|---|---|
people | Person[] | — |
groups | PeopleGroup[] | — |
search | (query, { signal }) => Promise<Person[] | PeopleGroup[]> | — |
searchDelay | number | 150 |
recent | Person[] | — |
value | Person[] | — |
defaultValue | Person[] | — |
onValueChange | (people: Person[]) => void | — |
multiple | boolean | false |
maxChips | number | — |
label | ReactNode | — |
hint | ReactNode | — |
placeholder | string | "Add people" |
searchPlaceholder | string | "Search people…" |
emptyText | ReactNode | — |
disabled | boolean | false |
wrapperClassName | string | — |
Accessibility
Combobox's roles, with people in them: each option is named by the person and their role, "Marta Nowak, Hiring manager" (a hidden comma joins them; the avatar is hidden). Recent and every titled group are groups named by their headers. While a search runs the last results stay, narrowed by the query; one that takes longer than 300 ms marks the list aria-busy. "Searching…", "No one matches" or a failed search are read out from a status region. A disabled person is aria-disabled. Each chip has a "Remove <name>" button; after a removal focus moves to the chip that takes its place, or to the field. The "+N" chip is a button named "Show N more"; it shows the rest and moves focus to the first of them.
| Key | Action |
|---|---|
| EnterorSpace | On the field: opens the list and focuses the search. |
| A–Z | In the search: filters by name, role and email, ignoring accents, or runs search after a pause. |
| ↑or↓ | Moves the highlight across the groups, wrapping at the ends. |
| Enter | Picks the highlighted person and, with multiple, drops one already picked; a single pick closes the list. |
| Esc | Closes the list and returns focus to the field. |
| Tab | Out of the field, through the chips' remove buttons and the "+N" chip. |
Something wrong or missing on this page?
Report a problemSuggest an improvement