Lookup component in Salesforce Lightning
Following source code is for Contact Lookup component.
<aura:attribute name="listOfSearchRecords" type="object[]" description="Use,for store the list of search records which returns from apex class"/>
<aura:attribute name="SearchKeyWord" type="string"/>
<aura:attribute name="Message" type="String" default="Search Result.."/>
<aura:attribute name="selectedRecordName" type="string"/>
<aura:attribute name="selectedRecordId" type="string"/>
<aura:handler event="aura:waiting" action="{!c.showSpinner}"/>
<aura:handler event="aura:doneWaiting" action="{!c.hideSpinner}"/>
<div class="">
<div aura:id="searchRes" class="slds-form-element slds-lookup slds-is-close" data-select="single">
<!--<label class="slds-form-element__label" for="lookup-348"> Account Name </label>-->
<!--This part is for display search bar for lookup-->
<div class="slds-form-element__control">
<div class="slds-input-has-icon slds-input-has-icon--right">
<lightning:icon aura:id="SearchID" class="slds-input__icon slds-show" iconName="utility:search" size="x-small" alternativeText="icon" />
<!-- This markup is for when an record is selected -->
<div aura:id="lookup-pill" class="slds-pill-container slds-hide">
<span class="slds-pill">
<span class="slds-pill__label">
{!v.selectedRecordName}
</span>
<button class="slds-button slds-button--icon slds-pill__remove" onclick="{!c.clear}">
<lightning:icon aura:id="RemoveID" class="slds-input__icon CloseIcn" iconName="utility:close" size="x-small" alternativeText="icon" />
<span class="slds-assistive-text">Remove</span>
</button>
</span>
</div>
<div aura:id="lookupField" class="slds-show">
<ui:inputText updateOn="keyup" keyup="{!c.keyPressController}" class="slds-lookup__search-input slds-input " value="{!v.SearchKeyWord}" placeholder="search.."/>
</div>
</div>
</div>
<!--This part is for Display typehead lookup result List-->
<div class="slds-lookup__menu slds" id="lookup-348">
<div class="slds-lookup__item--label slds-text-body--small">{!v.Message}</div>
<center> <ui:spinner aura:id="spinner"/> </center>
<ul class="slds-lookup__list" role="listbox">
<aura:iteration items="{!v.listOfSearchRecords}" var="singleRec">
<li role="presentation">
<span class="slds-lookup__item-action slds-media slds-media--center" id="lookup-option-350" role="option">
<div class="slds-media__body">
<div class="slds-input-has-icon slds-input-has-icon--right">
<!--Icon of Account -->
<div class="slds-lookup__result-text" title="{!singleRec.Name}" >
<a data-record="{!singleRec.Id+'#'+singleRec.Name}" onclick="{!c.selectAccount}">
{!singleRec.Name}
</a>
</div>
</div>
</div>
</span>
</li>
</aura:iteration>
</ul>
</div>
</div>
</div>
</aura:component>