How to add classes to every menu block placed within in a specific region? How do I add classes to menus but only when they appear within a certain region? Is there a way to do this in a theme?
you can augment the variables collection available to any twig file by tweaking the appropriate preprocess ... for example ... if you create the following function within your $THEME$.theme file:

function $THEME$_preprocess_block(&amp;$variables) {
  $block_id = $variables['elements']['#id'];
  $block = \Drupal\block\Entity\Block::load($block_id);
  $variables['region'] = $block-&gt;getRegion();
}


you can then access the newly defined region variable from within:

{{ region }}


you could then add your desired classes to menus but only when they appear within a certain regions:

{% set classes = 'menu' ~ ((region == 'header') ? ' menu-header') %}
{% block content %}
    &lt;nav {{ content_attributes.addClass(classes) }}&gt;
        {{ content }}
    &lt;/nav&gt;
{% endblock %}


that would add the class menu to all blocks and additionally would add the class menu-header to any block within the header region

hope that helps!