Drupal is a registered trademark of Dries Buytaert
Search API Solr 4.4.0 Minor update available for module search_api_solr (4.4.0). Page Manager 8.x-4.0 Major update available for module page_manager (8.x-4.0). Trash 3.1.0-beta2 New beta version released for module trash (3.1.0-beta2). Commerce AutoSKU 3.0.1 Minor update available for module commerce_autosku (3.0.1). Custom Field 4.0.10 Minor update available for module custom_field (4.0.10). Alternative login ID & display names 2.0.12 Minor update available for module alt_login (2.0.12). EntityReference UUID 3.0.1 Minor update available for module entity_reference_uuid (3.0.1). LocalGov Publications Importer 1.1.1 Minor update available for module localgov_publications_importer (1.1.1). Configuration Override Warn 8.x-1.6 Module config_override_warn updated after 10 months of inactivity (8.x-1.6). Table Alternate Rows Module table_altrow crossed 1,000 active installs.

This module allows you to add custom IDs, classes, styles, and data attributes to layout sections and their regions. It provides a user interface consistent with other attribute modules, allowing administrators to configure which attributes are available and for layout editors to apply them. For the added attributes to appear, the layout's template files must include the necessary variables to render them.

Adds possibility to add ID, class, style, data-* attributes to Layout Sections and for each Region in the Section.

The module is built with a similar UI as https://www.drupal.org/project/layout_builder_component_attributes
to provide a unified UX.

Install

The module requires *Php CSS Lint* (https://github.com/neilime/php-css-lint) for validating inline styles. If you install with composer it should be installed with it.

Usage

1. Enable Layout Custom Section Classes module.

2. Go to /admin/config/content/layout-builder-section-attributes to set up what attributes should be available to set. You can enable setting ID, class,
style, data-* attributes + you can predefine a class list.
Layout editors that way can select from predefined classes.
By default, every attribute from these will be available to use.

3. Set permissions:
- Administer Layout Builder Custom Section Classes settings:
this will provide access to /admin/config/content/layout-builder-section-attributes form.
- Administer Layout Builder Section Attributes:
this will provide access to edit section attributes in Layout Builder.
- Administer Layout Builder Section's Regions' Attributes:
this will provide access to edit section region attributes in Layout Builder.

4. Enable Layout Builder in manage display for a content type or taxonomy or whatever entity you're displaying with Layouts.

5. Add or Configure a section and there you can enter your settings for section as a whole and for each regions in the section.
Note that for ID or classes you must provide a valid class, so you can't use my!#class_1 because only my-class-1 will be valid. For setting styles, proper CSS syntax must be used.

Setting the classes won't be enough. You need to make sure that the layout (that you chose for the section) uses the {{ attributes }} variable in its template for section classes and attributes and also {{ region_attributes.REGIONNAME }} for each region classes and attributes. Because that variable contains the specified classes. An example for the variable usage is in Drupal core's layout--onecol.html.twig:

{%
  set classes = [
    'layout',
    'layout--onecol',
  ]
%}
{% if content %}
  <div {{ attributes.addClass(classes) }}>
    <div {{ region_attributes.content.addClass('layout__region') }}>
      {{ content.content }}
    </div>
  </div>
{% endif %}

Activity

Total releases
1
First release
Jun 2026
Latest release
1 month ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
2.1.0 Stable Jun 13, 2026