Employee Directory
Employee directory with search, alphabetical filter, dropdown filters, sort, and card/list views. Supports search mode and pinned employee mode.
Get Employee Directory Working in 4 Steps
Prerequisites
- Bonzai 2 package installed on your site
- User profiles configured in Azure AD / SharePoint
Add the web part to your page
Edit the page, click +, search for "Employee Directory", and add it to a section.
Set the Result Source
Open the property pane and select a Result Source. Use “Auto-detect (Recommended)” to let the web part pick the best option for your tenant, or choose “Local People Results” / a custom GUID if your organization uses a dedicated people result source.
Choose display mode
Select Search Directory (default) or Pinned Employees in the Display Mode section.
Enable filters and publish
Optionally enable filter dropdowns, sort, and view switching in View & Filter Options, then publish.
When to Use This Web Part
Use this when you need to...
- Create a company-wide employee directory
- Enable users to find colleagues by name or department
- Display contact information for employees
- Link to user profiles in SharePoint/Delve
- Browse employees alphabetically
- Show pinned employees on a team page
Best page locations
- People page — dedicated employee directory
- About Us page — company org overview
- Department pages — team member listings
- Contact page — find the right person
Consider alternatives when...
- • Displaying a specific list of featured people — use People Listing
- • Showing organizational hierarchy — use Org Chart solutions
- • Listing external contacts — use a custom list with People Listing
Related web parts:
Recent Updates
- New:
require:fieldrule in Exclusion Rules (Graph mode) — drops rows whose field is empty or whitespace-only (e.g.require:departmenthides accounts with no department). Pushed server-side as a Graph$filterso the result counter stays accurate. - Fixed: Graph mode now correctly handles company / department / office names containing special characters (
&,+,?,#, etc.). Previously, names like "First United Bank & Trust" produced 400 errors or "unterminated string literal" failures because the&split the query string.$filter,$select,$search, and$orderbyare now URL-encoded. - Improved: scatter-gather sorting in Microsoft Graph mode — sorting by Department / Job Title / Office now sorts the entire population (not just the current page). The service bulk-fetches across cursor pages and merges client-side.
- Improved: "Showing X-Y of Z" counter is now accurate in Graph mode after server-side filters and exclusion rules are applied.
@odata.countnow reflects the filtered population the user actually sees. - Internal: shared default constants (
DEFAULT_ITEMS_PER_PAGE = 28,DEFAULT_PINNED_ITEMS_PER_PAGE = 12,DEFAULT_PINNED_ITEMS_PER_ROW = 4) now drive the property-pane slider, render defaulting, and the React component in lockstep.
Display Modes & Views
- Search Directory: Full directory with search, A–Z filtering, filter dropdowns, sort, and Card/List views.
- Pinned Employees: Curated people list. Two selection methods:
- Select Individual Employees — pick specific people with a people picker.
- Filter by Criteria — pick a managed property (Department, Office Location, Job Title, or a custom property via
pinnedCriteriaCustomField) plus a value. The criteria value dropdown is populated with distinct values discovered in your tenant.
View Templates
- Card View (default): responsive grid of profile cards with a circular photo, name, title, department, and location. Email, phone, SIP/Teams, and other contact fields render as circular icon buttons at the bottom of each card.
- List View: compact row layout where every enabled non-image field becomes a column. The Name field renders as a brand-colored link, email and phone fields render as inline clickable text links, and the profile picture (when enabled) shows as a small avatar in the first column. On narrow viewports the column header row collapses.
Allow view switching
showViewSwitcher to let users toggle between Card and List at runtime.Profile photo fallback
PictureURL managed property. When that field is empty, the web part falls back to SharePoint’s default profile photo endpoint (/_layouts/15/userphoto.aspx). If the photo still fails to load (e.g., 404), the card or row renders the user’s initials in a circular Fluent UI Persona avatar.Filtering & Sorting
In Search Directory mode, you can add a toolbar that lets users narrow results with dropdown filters and change sorting. Filters and sort combine with search text and A–Z filtering.
- Filter dropdowns: Department, Office, Job Title, Company (configured via
filterFields) - Active filter chips: removable chips with “Clear all”
- Sort dropdown: Name (A–Z / Z–A), Department, Job Title, Office
- Exclude non-employee accounts: one toggle to exclude guests/rooms/equipment/shared mailboxes
Exclusion Rules (Graph Mode)
When the directory uses Microsoft Graph (shown as "Active data source: Microsoft Graph" in Page 2 settings), use the Exclusion Rules field to hide employees. Two rule kinds, one per line:
-company:CohnReznick # drop rows where company contains the value
-department:Terminations Org # case-insensitive substring match
-title:Contractor # any of name, email, department, title, office, company
require:department # NEW: drop rows where department is empty/whitespace
require:title # NEW: drop rows where title is empty/whitespaceRule Kinds
| Kind | Syntax | What it does |
|---|---|---|
| exclude | -field:value | Drops rows where the field contains the value (substring, case-insensitive). |
| require | require:field | Drops rows where the field is empty or whitespace-only. Also pushed server-side as a Graph $filter clause ({field} ne null) so the “Showing X-Y of Z” counter stays accurate. The client-side check still runs as a backstop for whitespace-only values that ne null can't catch alone. |
Available Fields
Both rule kinds use the same field tokens:
| Field | Exclude syntax | Require syntax | What it searches |
|---|---|---|---|
name | -name:value | require:name | Display name, first name, last name |
email | -email:value | require:email | Email address |
department | -department:value | require:department | Department |
title | -title:value | require:title | Job title |
office | -office:value | require:office | Office location |
company | -company:value | require:company | Company name |
Exclude matches are case-insensitive and use contains logic — -name:Admin matches "Administrator", "Admin Account", and "ADMIN". Quotes are optional for values with spaces. The directory automatically URL-encodes special characters (&, +, ?, #, etc.) so values like "First United Bank & Trust" no longer break the underlying Graph request.
Custom Query Filter (SharePoint Search Mode)
When the directory uses SharePoint People Search, use the Custom Query Filter field with KQL (Keyword Query Language) syntax:
-Department:"Terminations Organization" -JobTitle:Contractor -WorkEmail:vendor -SPS-UserType:1Common KQL Properties
| Property | Description | Example |
|---|---|---|
PreferredName | Display name | -"PreferredName":"Conf Room" |
WorkEmail | Email address | -WorkEmail:vendor |
Department | Department | -Department:"Terminations Organization" |
JobTitle | Job title | -JobTitle:Intern |
OfficeNumber | Office location | -OfficeNumber:Building-C |
SPS-UserType | User type (1 = external) | -SPS-UserType:1 |
SPS-HideFromAddressLists | Hidden from GAL | -SPS-HideFromAddressLists:1 |
SPS-RecipientTypeDetails | Mailbox type | -SPS-RecipientTypeDetails:=16 (rooms) |
KQL property names are case-sensitive. Values with spaces must be quoted. Multiple exclusions can be on one line separated by spaces. Use = for exact match (e.g., -SPS-RecipientTypeDetails:=16).
Which filter system am I using?
graphExclusions). If it says “SharePoint People Search”, use Custom Query Filter (queryFilter). The Exclude Non-Employee Accountstoggle works in both modes. In Graph mode, queryFilter is ignored and a warning is logged to the console.Configure Fields
- Enable/disable fields, reorder, and choose managed properties
- Select display type per field (Text, Email Link, Phone Link, Link, Icon + Text, Image)
- The Display Name you set becomes the column header in List View
- Reorder fields to control the column order in List View
- Reset to default if needed
Configure Fields controls List View columns
Step-by-Step Configuration
Navigate to your target page
Add a section with appropriate width
Add the Employee Directory web part
Configure the title
Leave blank for a cleaner look if the page title already indicates the purpose.
Select display mode
Configure pinned options (if used)
Set items per page
Configure view options
Enable filters and sort
Set up exclusions (optional)
Configure fields
Publish and test
Common Configurations
Copy these ready-to-use configurations:
Company Directory
Full directory with all features enabled
| title | Employee Directory |
| itemsPerPage | 28 |
| displayMode | Search Directory |
| enableWildcardSearch | On |
Department Team Page
Compact directory for team pages
| title | Our Team |
| displayMode | Pinned Employees |
| pinnedSelectionMode | Select Individuals |
| pinnedItemsPerRow | 4 |
| pinnedItemsPerPage | 12 |
Quick People Search
Search-focused minimal directory
| title | Find a Colleague |
| searchText | Search employees... |
| itemsPerPage | 8 |
| displayMode | Search Directory |
Browse by Name
Alphabetical browsing focus
| title | Staff Directory |
| alphabeticalFilterField | PreferredName |
| itemsPerPage | 20 |
| displayMode | Search Directory |
| fieldConfigJson | Name, Role, Location enabled |
Filtered Company Directory
Directory with department, office, and role filters
| title | Employee Directory |
| displayMode | Search Directory |
| enableFilters | On |
| enableSortDropdown | On |
| showViewSwitcher | On |
| enableStandardExclusions | On |
| itemsPerPage | 28 |
Clean Directory
Excludes conference rooms, contractors, and external users
| title | Employee Directory |
| displayMode | Search Directory |
| enableStandardExclusions | On |
| queryFilter | -JobTitle:Contractor |
| enableWildcardSearch | On |
Best Practices
Ensure user profiles are complete
Use on a full-width section for large organizations
Use the standard exclusions toggle for clean results
enableStandardExclusions to filter these out automatically instead of building custom query transforms.List View for data-dense directories
Combine with People Listing for featured staff
Search indexing may affect results
Reference
Technical details for developers and advanced users.
Property Pane Configuration
Settings are split across two pages in the property pane. Page 1 contains the settings most users need. Page 2 contains advanced settings and adapts based on the detected data source (SharePoint Search vs Microsoft Graph).
Page 1 · General Settings
| Property | Type | Description |
|---|---|---|
title | Text | Web part title (default: Employee Directory). Leave blank to hide the title and icon row entirely. |
titleIconName | Icon Picker | Fluent UI icon rendered next to the title (default: ContactCard) |
itemsPerPage | Slider (4-100) | Results displayed per page in Search Directory mode (step: 4, default: 28) |
Page 1 · Display Mode
| Property | Type | Description |
|---|---|---|
displayMode | Choice | Search Directory (default) or Pinned Employees |
pinnedSelectionMode | Choice | Select Individual Employees or Filter by Criteria |
pinnedEmployees | People Picker | Multi-select people (individual mode only) |
pinnedCriteriaField | Dropdown | Managed property to filter by in criteria mode (default: Department). Common options are Department, OfficeNumber, and JobTitle. The dropdown is populated with managed properties discovered in your tenant, plus a custom option for arbitrary properties. |
pinnedCriteriaCustomField | Text | Custom managed property name. Only used when pinnedCriteriaField is set tocustom. |
pinnedCriteriaValue | Dropdown / Text | Value for the selected criteria field. Renders as a dropdown populated with distinct values from your tenant when available, or as a text field while values are loading. |
Page 1 · Pinned Layout (Pinned mode only)
| Property | Type | Description |
|---|---|---|
pinnedItemsPerRow | Slider (1-6) | Number of employee cards per row (default: 4) |
pinnedItemsPerPage | Slider (1-50) | Employees per page (default: 12) |
Page 1 · View & Filter Options (Search Directory mode)
| Property | Type | Description |
|---|---|---|
templateName | Dropdown | Default view: card or list (default: card) |
showViewSwitcher | Toggle | Allow runtime view switching between Card and List (default: Off) |
enableFilters | Toggle | Show filter dropdowns above the results (default: Off). Populated from SharePoint Search refiners or Graph aggregation. |
enableSortDropdown | Toggle | Show sort dropdown (default: Off). Options: Name A–Z / Z–A, Department, Job Title, Office. |
Page 1 · Display Fields
| Property | Type | Description |
|---|---|---|
fieldConfigJson | Collection (serialized JSON) | Field list controlled by the Configure Fields panel. Each field has an ID, label, managed property, display type (text, email, phone, link,icon-text, image), optional icon name, enabled flag, and order. |
customFieldsJson | Serialized JSON | Secondary storage for user-defined custom fields. Merged into the effective field list at render time. The Reset to Default button in the property pane clears both fieldConfigJson andcustomFieldsJson. |
Page 2 · Data Source
| Property | Type | Description |
|---|---|---|
resultSource | Dropdown / Text | Data source selection (default: auto). Options include “Auto-detect (Recommended)”, named SharePoint Search result sources discovered in your tenant, and “Custom (enter GUID)”. This group is hidden when the data source has been auto-detected as Microsoft Graph. |
enableStandardExclusions | Toggle | Exclude external users, conference rooms, equipment mailboxes, shared/team mailboxes, and accounts hidden from the address list (default: On). Works in both SharePoint Search and Microsoft Graph modes. |
queryFilter | Multiline Text | Custom KQL filter appended to every search (e.g., -Department:Contractors). Only shown in SharePoint Search mode; ignored with a console warning in Microsoft Graph mode. |
graphExclusions | Multiline Text | Exclusion rules applied in Microsoft Graph mode. Two rule kinds, one per line: -field:value drops rows whose field contains the value (substring, case-insensitive); require:field drops rows whose field is empty or whitespace-only and is also pushed server-side as a Graph $filter. Supported fields: name, email, department, title, office, company. Only shown when the detected data source is Microsoft Graph. |
Microsoft Graph fallback (auto-detect)
sourceid), then falls back to Microsoft Graph /users if none return people. Graph mode requires admin approval of the solution’s Graph permission request (User.Read.All). When active, the Data Source group on Page 2 showsActive data source: Microsoft Graph (Azure AD).Page 2 · Search Tuning (SharePoint Search mode only)
| Property | Type | Description |
|---|---|---|
alphabeticalFilterField | Text | Managed property used for A–Z filtering (default: PreferredName). Falls back to PreferredName automatically if the configured field fails. |
enableWildcardSearch | Toggle | Append * to search terms for partial matches (default: On) |
trimDuplicates | Toggle | Pass trimduplicates=true to SharePoint Search (default: Off) |
filterFields | Text | Comma-separated managed properties for filter dropdowns (default: Department,OfficeNumber,JobTitle,Company). Only meaningful when enableFilters is on. |
Page 2 · Customization
| Property | Type | Description |
|---|---|---|
searchText | Text | Placeholder text for the search box (default: Search) |
titleIconUrl | Text | Custom icon URL that overrides titleIconName. Hidden when title is blank. |
additionalLinkText | Text | Text for an additional link rendered to the right of the title |
additionalLinkUrl | Text | URL for the additional link (opens in a new tab with noopener noreferrer) |
Features Checklist
- Name search (with optional wildcard matching)
- Alphabetical A–Z filter with automatic fallback to
PreferredNameif the configured field fails - Profile photos from Azure AD / Microsoft 365, with fallback to SharePoint’s user photo endpoint and initials avatar
- Contact fields: email, work phone, mobile phone, SIP/Teams address (all configurable)
- Profile links to Delve / SharePoint profile (SP Search mode) or Delve by user id (Graph mode)
- Pagination (cursor-based when using Microsoft Graph)
- Pinned Employees mode — individual picker or filter-by-criteria
- Configurable fields via Configure Fields collection editor with reorder, enable/disable, and custom display types
- Responsive grid layout (Card view) and dynamic column layout (List view)
- Runtime view switching (Card/List toggle)
- Filter dropdowns populated from Search refiners or Graph aggregation
- Active filter chips with dismiss and Clear All
- Sort dropdown (Name, Department, Job Title, Office) — applied server-side in SharePoint Search mode; in Graph mode, sort is a hybrid of
$orderbyplus a client-side scatter-gather merge across cursor pages so non-Name sorts cover the entire population - Standard non-employee exclusions toggle (external users, rooms, equipment, shared mailboxes, hidden from GAL)
- Custom KQL query filter (SP Search) or client-side exclusion rules (Graph)
- People content class enforcement (
contentclass:spspeople) in every search to prevent non-people results - Progressive search fallback — retries with reduced
selectproperties/sortlistif SharePoint returns 500 - Microsoft Graph
/usersfallback when People Search is unavailable
Data Source
Employee Directory talks to two data sources and chooses between them automatically:
- SharePoint People Search API (
/_api/search/query) — the default. Indexes Azure AD user profiles, SharePoint user profile properties, and Microsoft 365 profile information. Supports KQL query filters, managed property refiners, and configurable result sources. - Microsoft Graph
/users— automatic fallback when People Search returns no results or is unavailable. RequiresUser.Read.Allto be approved for the Bonzai 2 package. Supports$filter,$orderby,$search, and cursor-based (@odata.nextLink) pagination.
Migration from Classic
| Aspect | Classic | Modern |
|---|---|---|
| Technology | bonzai.min.js + JSOM | SPFx + People Search API, with Microsoft Graph fallback |
| Photos | SharePoint User Profile | Azure AD / M365 Profile |
| Profile Links | MySite | Delve / SharePoint Profile |
| Result Source Filters | Site Settings query transform | Built-in exclusions toggle + custom query filter |
| View Modes | Single view | Card View + List View with runtime toggle |
| Filtering | By custom query transform only | Interactive dropdowns (Department, Office, Job Title) |
| Sorting | Not configurable | Sort dropdown (Name, Department, Job Title, Office) |