This project is not covered by Drupal’s security advisory policy.

About

Layout Builder lets you place blocks into layouts, but it has no answer to the question when a block or a whole layout should be shown. Component visibility adds that missing piece: every block and every section gets a Visibility tab, configured with the same condition plugins core already uses for block visibility.

Conditions are evaluated while the entity is rendered. A component whose conditions do not pass is removed from the render array, and its cacheability is kept intact, so pages stay cacheable.

Features

  • Visibility conditions on individual Layout Builder blocks.
  • Visibility conditions on whole sections, hiding the layout and everything in it.
  • Every condition plugin works, including those provided by contrib and custom modules.
  • Conditions are combined with an "and" or an "or" operator.
  • Components stay visible inside the Layout Builder preview, so a component that is hidden on the live page can still be edited.
  • A condition whose context is missing hides the component and warns, instead of breaking the page.

Requirements

Drupal 10.3 or newer with the core Layout Builder module, plus Form decorator and Conditions. Both are installed automatically by Composer.

Getting started

Install with composer require drupal/component_visibility and enable the module. Enable Layout Builder for an entity view display, then edit the layout: the configuration form of every block and every section now carries a Visibility tab. Pick the conditions the component has to satisfy, choose whether all or any of them must pass, and save the layout.

Supporting organizations: 
Development and maintenance

Project information

Releases