How can I programmatically get the theme name?
Using the theme manager is the proper Drupal 8 way of getting information about your theme.

\Drupal::service('theme.manager')-&gt;getActiveTheme()


A general rule in drupal 8 is look for the manager (/handler) service.

** Note: as Neograph734 pointed out, \Drupal::service('theme.manager')-&gt;getActiveTheme() will return the active theme object. If you want to get the theme machine-name then use \Drupal::service('theme.manager')-&gt;getActiveTheme()-&gt;getName()