• jpoesen
  • about
  • articles
  • talks
  • opensource

Drupal 8/9: Adding CSS body classes based on the current user's roles

Joeri Poesen // 2021-05-03

Sometimes it's useful to add body classes based on the current Drupal user's roles.

This article shows how to do this by adding or modifying a template_preprocess_html() implementation in your .theme file.

No twig modifications or plugins required.


Continue reading the full article over at https://trainingcloud.io/blog/2021/05/drupal-8-9-adding-css-body-classes-based-on-user-roles/

Hire me for Drupal mentoring & consultancy.
Learn Drupal with me on TrainingCloud.io - PHP & Drupal training with a heart.