Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

Summary

This module gives you the ability to define a list of classes and labels that will be available for selection on each section of a layout in layout builder. To enable this feature, simply add the list of classes to your layout plugin:

landing_one_column:
  label: One column
  category: Landing page layouts
  template: layouts/landing-pages/landing-one-column
  classes:
    style:
      label: 'Style'
      multiple: true
      required: false
      options:
        'background--primary-light': 'Light background'
        'background--wave-dark background--primary-light': 'Wave background'
      description: 'Select the visual style for this region.'
      region_classes:
        'background--primary-light':
          content: 'this-class-ends-up-on-the-content-region-for-this-style'
    spacing:
      label: 'Spacing'
      multiple: false
      required: true
      default: 'section--bottom-l section--top-l'
      options:
        'section--bottom-l section--top-l': 'Standard'
        'section--bottom-s section--top-s': 'Tight'
      description: 'Select the spacing that will be applied to this region.'
  regions:
    content:
      label: Content

A layout definition like the above produces a layout form that looks like:

You may choose to:

  • Allow multiple or single classes for each group of styles.
  • Optionally enforce if a selection is required or not for each group of styles.
  • Optionally provide a default value for each group of styles.
  • Associate a class with classes on the regions inside the layout

The simplest definition possible would look something like:

landing_one_column:
...
  classes:
    my_set_of_classes:
      options:
        'foo': 'Foo classes'
        'bar baz': 'Bar and baz classes'
...

Reusing definitions

You can define a reference using the & symbol, e.g. this at the top of your file defines a 'spacing' variant.

spacing: &spacing
  label: 'Spacing'
  require: true
  default: 'section'
  options:
    'section--no-padding': 'None'
    'section--half-padding': 'Small'
    'section': 'Large'

Then you can use that in your definitions like so:

one_column:
  label: One column
  category: Layouts
  template: layouts/one-column
  classes:
    spacing:
      <<: *spacing

Similar modules

This module is slightly different to Layout Builder Styles in that:

  • It does not use additional configuration to define the styles/classes that are selectable by users.
  • It does not provide any features for block template suggestions.
  • It does not require the user provide their own plugin class for their layouts.
  • It will not work if a layout has already provided it's own custom plugin class.

If you require those features, please have a look at the above module.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
3
Tracked since
Oct 2023
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Release Timeline

Releases

Version Type Core Release date
8.x-1.6 Stable Jul 19, 2024
8.x-1.5 Stable Dec 12, 2023
8.x-1.4 Stable Oct 24, 2023