How can get the current region inside the 'hook_preprocess_block'? How can I get the current region name inside the hook_preprocess_block()?
I tried the following code, but it seems something is wrong.

function ThemeName_preprocess_block(&amp;$variables) {
  if ($variables['elements']['#region'] == "nav") {
    $variables['attributes']['class'][] = 'SomeStyle';
  }
}
As described in the documentation for template_preprocess_block(), 
$variables['elements']['#block'] is available, and it contains the Block object. With that, you can get the region to which the block is assigned with Block::getRegion().

function ThemeName_preprocess_block(&amp;$variables) {
  if (isset($variables['elements']['#block']) &amp;&amp; $variables['elements']['#block']-&gt;getRegion() == 'nav') {
    $variables['attributes']['class'][] = 'SomeStyle';
  }
}


That is slightly different from Drupal 7, where hook_preprocess_block() would get the region assigned to the block from $variables['block']-&gt;region, or from $variables['elements']['#block']-&gt;region. See template_preprocess_block() (Drupal 7).

  $block_counter = &amp;drupal_static(__FUNCTION__, array());
  $variables['block'] = $variables['elements']['#block'];
  // All blocks get an independent counter for each region.
  if (!isset($block_counter[$variables['block']-&gt;region])) {
    $block_counter[$variables['block']-&gt;region] = 1;
  }