-1

I am trying to add CSS classes to a new region {{ page.example }} in page.html.twig

In the start of page.html.twig, I have added a set of CSS classes:

{%
set classes = [
  'region--content', 
  'grid-full', 
  'layout--pass--content-medium',
]
%}

When I try to apply them to an element as follows, this element just disappears from my node.

{{ page.example.addClass(classes) }}

What have I done wrong?

3

1 Answer 1

0

I didn't find a simple way to add at least one class with Twig so I have added classes with HTML this way:

<div class="region--content grid-full layout--pass--content-medium">
  {{ page.example }}
</div>

I have flushed all caches of Drupal with Drush and flushed all caches of the web browser to test the webpage appearance and indeed found this change to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.