Employee Directory Web Part Using Modern People Search SharePoint Online

Introduction 

 
One of our clients wanted to show an Employee Directory. Our first suggestion was to build a custom SPFx, which will fetch data from Azure AD or Delve and add it on the page. However, the client wanted to use the OOTB feature and asked us if we can get something out of the people webpart.
 
From there, we invented the Employee Directory using Modern Search. Follow the below steps in case you want to implement it on your end.
 
Prerequisite
 
Install the Script Editor webpart. You can download the code from here.
 
Follow the below steps to set up the Employee Directory Webpart,
 
Step 1
 
Go to Modern SharePoint Site. Add embed webpart in your page. Type the below URL:
  1. <iframe id="peopleSearchFrame" src="Your Office 365 Site URL/_layouts/15/search.aspx/people" width="3000" height="6000" scrolling="no"></iframe>    
Step 2
 
Add the script editor webpart below the embed webpart.
 
Step 3
 
Add the below custom css / js to hide unwanted things.
  1.  <script src='https://code.jquery.com/jquery-2.2.4.min.js'></script>    <script>      
  2.    var myTimerVar = setInterval(designSearch, 20);      
  3.    function designSearch() {      
  4.       $($("iframe")[0]).contents().find('#ms-searchux-serp h2').hide();      
  5.       $($($("iframe")[0]).contents().find(".ms-Button-flexContainer")).hide();      
  6.       $($($("iframe")[0]).contents().find(".SPSearchUX-module__searchFilters___s1xp2")).hide();       
  7.       //CSS for search box and result      
  8.       $($($("iframe")[0]).contents().find("#ms-searchux-serp div")[0]).css("padding","0 0 0 0px");      
  9.       $($($("iframe")[0]).contents().find("#ms-searchux-serp div")[0]).css("border","0");      
  10.       $($($("iframe")[0]).contents().find("#ms-searchux-serp div")[0]).css("padding","8px");      
  11.       $($($("iframe")[0]).contents().find(".ms-searchux").parent('div')).css("padding","0 0 0 0px");      
  12.       $($($("iframe")[0]).contents().find(".ms-searchux").parent('div')).css("border","0");      
  13.       $($($("iframe")[0]).contents().find(".ms-searchux").parent('div')).css("padding","8px");      
  14.       $("[data-automation-id=pageHeader]").find("[role=heading]").css("border-bottom","2px solid #454545");      
  15.       $("[data-automation-id=pageHeader]").find("[role=heading]").css("color","#454545");      
  16.       $("[data-automation-id=pageHeader]").find("[role=heading]").css("font-weight","700");      
  17.       $("[data-automation-id=pageHeader]").find("[role=heading]").css("font-size","20px");      
  18.       $("[data-automation-id=pageHeader]").find("[role=heading]").css("padding-bottom","11px");      
  19.       $("[data-automation-id=pageHeader]").find("[role=heading]").css("text-transform","capitalize");      
  20.       $($($("iframe")[0]).contents().find(".SPSearchUX-module__searchFilters___12Rv7")).hide();      
  21.       $($($("iframe")[0]).contents().find("div[class^='backLinkWrapper_']")).hide();      
  22.       $($('div[class="ControlZone"]')[0]).css('padding''0');      
  23.       $('div[class^="contentBox_"]').css('padding-bottom''0');      
  24.    }      
  25. </script>     
Once done, you will see output as follows: