Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Configuration Language Lock 1.0.2 Minor update available for module config_language_lock (1.0.2). Release: Canvas Override 1.0.1 Minor update available for module canvas_override (1.0.1). Release: Media Remote Image 8.x-1.2 Minor update available for module media_entity_remote_image (8.x-1.2). Release: IDNA Convert Service (punycode) 2.0.4 Minor update available for module idna (2.0.4). Release: Bootstrap Cloud 7.1.3 Minor update available for theme bootstrap_cloud (7.1.3). Release: Token Browser 1.0.2 Minor update available for module token_browser (1.0.2). Release: Varbase Project 11.0.8 Minor update available for module varbase_project (11.0.8). Release: Media Remote Image 2.0.0-beta1 First beta version released for module media_entity_remote_image (2.0.0-beta1). Usage Milestone: Term CSV Export Import Module term_csv_export_import crossed 1,000 active installs. Security Coverage: Module Scout Module module_scout now has official Drupal security advisory coverage.

Layout Custom Section Classes & Attributes

3,104 sites Security covered Drupal 9–11
View on drupal.org

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 %}

Depends on

Dependencies of the latest stable release

  • layout_builder Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Jun 2026
Latest release
2 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Active

Releases

Version Type Core Release date
2.1.0 Stable 9–11 Jun 13, 2026