SharePoint Online customize search box web part

This SharePoint search tutorial explains how to customize the search box web part properties in SharePoint Online/2016/2013. We will also see how to set the search box for a particular search result web part in SharePoint.

In SharePoint, when the user will type in the search box then the result will populate in the search result web part. We will also see how to change the text of the Search box web part. By default in the search box web part, it is coming “search”, how we will change to “Search here” in the search box web part.

SharePoint Online search box web part

The Search box web part displays a text box where the user can enter their queries for the information in SharePoint Online.

Add “Search Box” web part to web SharePoint part page

Now we will see how to add a Search box web part in a SharePoint web part page in SharePoint Online or SharePoint 2013/2016.

Open SharePoint web part page and click on Edit the web part page. Click on Add a web part and choose Search Box from Search web part categories.

sharepoint online customize search box web part
advanced search box in sharepoint 2013

Configure Search Box web part

Go to the “Site Settings” -> Edit page. Go to the “Edit Web part” of particular web part.

Expand “Which search result page should queries to be send to?”.

Below the “Use this site’s Search Settings” we will see all the search results web part name which is present in the web part page. In my web part page only one Search results” web part is present. Whatever we will choose the “search result web part” name, then the query will be sent to the that search result web part.

SharePoint online search box web part
SharePoint online search box web part

When we search in the search box then the result is displaying in the Search result page. I have searched “NewXL” in the Search box web part, So “NewXL” is selected in the search result web part.

SharePoint search web part
SharePoint search web part

Change default text search box SharePoint Online/2013/2016

Now we will see one example of how to customize the SharePoint online search box web part. We will see how to change the “Search” text to “Search here” inside the text box. For that follow the below steps.

SharePoint online search web part
SharePoint online search web part

Step-1: First go to SharePoint online “Site Settings”

SharePoint online search web part
SharePoint online search web part

Step-2: In the “Master Page Gallery” page select on “Display Templates”.

See also  Power Apps Search SharePoint List Examples
SharePoint online search box web part
SharePoint online search box web part

Step-3: Select the “Search” in the “Display Templates” page.

SharePoint 2013 search box web part
SharePoint 2013 search box web part

Step-4: In the Search page search for “Control SearchBox.html” right click on it and “Download a Copy” in the local system. Remember that do not touch the js file.

SharePoint online search box
SharePoint online search box

Open the HTML file in your favorite editor. Then change the title, I have changed that “Demo SearchBox SharePoint” below the <head>. Then search for

if ($isNull(prompt))
         {
             prompt = Srch.Res.sb_Prompt;
         }

in the body part of html file. then change to

if ($isNull(prompt))
         {
             prompt = "Search here";
         }  

Change the title tag value. Here I have changed to “Demo SearchBox SharePoint”.

<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> 
<head>
<title>Demo SearchBox SharePoint</title>

<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string">Displays the Search Box control.</mso:MasterPageDescription>
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106601</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#SearchBox;#</mso:TargetControlType>
<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>
<body>
    <div id="Control_SearchBox">
<!--#_ 
        var showQuerySuggestions = ctx.ClientControl.get_showQuerySuggestions();
        var showNavigation = ctx.ClientControl.get_showNavigation();

        var prompt = ctx.ClientControl.get_initialPrompt();
        if ($isNull(prompt))
        {
            prompt ="Search Here";
        }

Then Save the html file and rename it. Upload the HTML file to Display Template -> Search. Here I have uploded “SearchBox.html”. When we upload the html file then the js file will created automatically. Donot touch the js file.

SharePoint online search box web part
SharePoint online search box web part

Go to the Site page. Then go to edit site page. And go to particular that web part “Edit Web Part” page. Expand the “Settings”. In the “Search box control Display Template” field choose the “Demo SearchBox SharePoint(what ever we given in the html page title tag”. Click on Apply and OK.

SharePoint search web part
SharePoint search web part

Save the page. We can able to see the text is changed to “Search here”. Check the below screenshot.

SharePoint online search box
SharePoint online search box

You may like following SharePoint search tutorials:

See also  Setup and Manage Access Request Settings in SharePoint Online/2013/2016

I hope this SharePoint online “Search box” web part helpful to you. We knew how to add the Search box web part. We also knew how to send the search box value to particular search result web part. We saw how to change the “Search box” web part text box text to “Search here”.

>