How to add the view name as body class
this one worked:

function THEMENAME_preprocess_html(&amp;$variables) { 
  //view name as body class
  $variables['view_title'] = '';
  $route = \Drupal::routeMatch()-&gt;getRouteObject();
  if ($route) {
    $view_title = $route-&gt;getDefault('_title');
    $variables['attributes']['class'][] = 'view-' . $view_title;
  }
}