Drupal 9: Theme Hook To Add User Template Suggestions

 * Implements hook_theme_suggestions_HOOK_alter().
function THEME_theme_suggestions_user_alter(array &$suggestions, array $variables) {
  // Get the view mode.
  $mode = $variables['elements']['#view_mode'];

  // Create a theme hook suggestion which has the view mode name in it.
  $suggestions[] = 'user__' . $mode;

Create theme templates with in the following way.

user--<view mode>.html.twig


Add new comment

The content of this field is kept private and will not be shown publicly.