In this post I am going to explain how to remove block from layout on specific condition Magento 2.

If you have a specific condition to add/remove block then you can achieve it by observer.

Here I have given the example to remove search block.

First you need to create event.xml file on below path.

Path: app/code/<vendor>/<module>/etc/frontend/events.xml

Now, create observer on below path.

Path: app/code/<vendor>/<module>/Observer/RemoveBlockSearch.php

After adding above code, search block will removed from the Header.