Get Username from UID with Preprocess for Template I'm a bit lost at finding the username based on the uid. I get the uid from the address using: 

  $current_path = \Drupal::service('path.current')-&gt;getPath();
  $urluid = (explode("/",$current_path));

  $us = \Drupal::entityTypeManager()-&gt;getStorage('user')
  -&gt;loadByProperties(['uid' =&gt; $urluid[2]]);

  kint($us);


returns an array of data where i do see the uid, but not the username for that uid. Name:

'name' =&gt; array(1)
*DEPTH TOO GREAT*


returns NULL:

kint($us-&gt;name);


I'd like to return the UID->Name as the title on the ROLES and EDIT screens for the user. Exactly how it is returned for VIEW (example dvweb is: /user/10):


EDIT:::

Was able to get it with: 

  $u = Drupal\user\Entity\User::load($urluid[2]);
    kint($u-&gt;getUsername());
It's better to use the route instead of the path, where you'll find the already loaded user entity:

if (\Drupal::routeMatch()-&gt;getRouteName() == 'entity.user.canonical') {
  $user = \Drupal::routeMatch()-&gt;getParameter('user');
  $username = $user-&gt;getUsername();
}