How to collapse the search icon

Hi,
How can you aid me create an initial collapse state of the search icon and a ease/slide out to the when clicked?

Screenshot: