Set CSS class for a View programmatically in a hook I want to set an extra class for the first page of a paged View.

/**
 * Implements hook_views_pre_render().
 */
function my_module_views_pre_render(ViewExecutable $view) {
  if ($view-&gt;id() === 'my_view' &amp;&amp; $view-&gt;current_display === 'page_1') {
    // Somehow set/override the css class here.
  }
}


How can I change the CSS class set in the advanced settings of the View?
Something like this should do it:

$view-&gt;display_handler-&gt;setOption('css_class', 'your_class');


Good luck!