How can I add special classes to only all blocks that's generated in certain region? I want to add some classes to each block that generated in custom region automatically.
For example I want to all blocks that generated within sidebar-left have some special classes and in addition I don't want to those blocks in other regions have those classes.

I try to use something like below code to add desired class to each block that's generated in sidebar-left:

region--sidebar-left.html.twig

{%
  set classes = [
    'region',
    'region-' ~ region,
  ]
%}
{% if content %}
  &lt;div{{ attributes.addClass(classes) }}&gt;
    {{ content }}
  &lt;/div&gt;
{% endif %}


But it seems there isn't any loop functionality Like below to I can use for each blocks and add my desired classes to them:

{% for item in items %}
  &lt;div class="my-desired-class"&gt;
    {{ content }}
  &lt;/div&gt;
{% endif %}
I am afraid this is no longer possible, according to Region-specific block templates are not available in Drupal 8.


  In Drupal 7 it was possible to specify separate block templates per
  region, such as block--header.tpl.php and block--footer.php to output
  different HTML for blocks placed in the header and footer regions. It
  was also possible to adjust variables based on region in
  hook_preprocess_block(). Both of these features have been removed.
  
  It is suggested you use standard CSS cascading selectors to style
  blocks differently on different parts of the page.


Therefore, you have 2 options:

1) In your page.html.twig you add a parent/wrapper class or id

{% if page.sidebar %}
    &lt;div class="my-sidebar"&gt;
       {{ page.sidebar}}
    &lt;/div&gt;   
{% endif %}


Then in CSS use your parent/wrapper to style your blocks .my-sidebar .block { border: solid red; }

2) Individually create a block--block--[id].html.twig for each of your sidebar blocks and add my-desired-class here.