Passing taxonomy term through drupal_html_class() and use it as row class name
I got it working by using this preprocess function:

function mytheme_preprocess_views_view_field(&amp;$variables) {
  $view = $variables['view'];
  $field = $variables['field'];
  if ($view-&gt;id() == 'VIEW_NAME' &amp;&amp; $view-&gt;current_display == 'DISPLAY_NAME') {
    if ($field-&gt;field == 'field_category') {
      $tid = $variables['row']-&gt;_entity-&gt;field_category-&gt;target_id;
      $term = \Drupal::entityTypeManager()-&gt;getStorage('taxonomy_term')-&gt;load($tid);
      $name = $term-&gt;getName();
      $variables['output'] = \Drupal\Component\Utility\Html::cleanCssIdentifier($name);
    }
  }
}


An alternative would be using mytheme_views_pre_render.