Difference between attributes remove and display true|false in the layout

This article will help you to understand the basic difference between attributes remove and display true|false in Magento 2 layout.

Remove attribute

  • Allows to remove or cancel the removal of the element. When a container is removed, its child elements are removed as well.
  • The remove attribute is optional and its default value is false.
  • This implementation allows you to cancel the removal of a block or container in your layout by setting remove attribute value to true.
  • Possible values are true and false.

Example:

<referenceBlock name="block.name" remove="true" />

Display attribute

  • Allows you to disable rendering of a specific block or container with all its children (both set directly and by reference). The block's/container's and its children' respective PHP objects are still generated and available for manipulation.
  • The display attribute is optional and its default value is true.
  • You are always able to overwrite this value in your layout. In the situation when remove value is true, the display attribute is ignored.
  • Possible values are true and false.

Example:

<referenceContainer name="container.name" display="false" />
  • Share :