Change record status: 
Project: 
Introduced in branch: 
Introduced in version: 
Description: 

Drupal Core has a new core/filter-empty-container library which applies display: none to elements marked with data-filter-empty-container when they match CSS :empty.

The element stays in the DOM and can become hidden when a render placeholder is replaced with empty output, including by BigPipe.

Core’s region preprocess attaches the library and adds the attribute to region wrappers.

If your theme overrides region.html.twig, keep {{ attributes }} on the wrapper so it retains data-filter-empty-container. Use {{- content -}} to trim the surrounding template whitespace so the wrapper can match :empty when the content renders nothing.

{% if content %}
  <div{{ attributes }}>
    {{- content -}}
  </div>
{% endif %}

Themes and modules can also use the library for other containers. In a Twig template without preprocessing, attach the library and add the attribute to the element to hide when empty.

{{ attach_library('core/filter-empty-container') }}
<div data-filter-empty-container>{{- content -}}</div>
Impacts: 
Module developers
Themers