container theme suggestions for views drupal 8 code example

Example: theme hook suggestion for container drupal 8

/**
 * Implements hook_theme_suggestions_alter() for contact form container.
 */
function THEMENAME_theme_suggestions_container_alter(array &$suggestions, array &$variables)
{
  $name = '';
  $type = '';
  if (isset($variables['element']['#name'])) {
    $name = $variables['element']['#name'];
  }

  if (isset($variables['element']['#type'])) {
    $type = $variables['element']['#type'];
  }

  array_unshift($suggestions, 'container__' . $type . '__' . $name);
}

Tags:

Misc Example