I want to edit default search bar in Magento 2. What I would like to have is to display the search icon and when the customer clicks the icon I want to show the search bar.

To do that, where to update the code?

Can anyone please guide me?

  • Can you please post demo image or something else? Commented Oct 4, 2019 at 6:02
  • Edit this file: vendor/magento/module-catalog-search/view/frontend/templates/result.phtml Commented Oct 4, 2019 at 7:49

1 Answer 1


You need to do some thing like this one.

  1. Create one custom extension and overide magento 2 default search file into extension. for that one create the default.xml file at following location.


<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="header-wrapper">
            <referenceBlock name="top.search">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">Vendor_Extension::form.mini.phtml</argument>
  1. now copy form.mini.phtml phtml from




Now you can change, what every you want to do here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.