Wordpress - How to get the active theme's slug?

You can get the slug in the options table, stored under the name stylesheet.

echo get_option('stylesheet');

Short Answer: get_stylesheet();

There is technically no 'slug' value for a theme. The name of a given theme's directory is what you want.

get_template();

…will return the directory name of your theme, or the parent theme in the case that your current theme is a child theme.

get_option('stylesheet');

Will ALWAYS return the directory name of your active theme, whether or not it is a child theme.

get_stylesheet();

Will ALWAYS return the directory name of your active theme, whether or not it is a child theme. This function is essentially a wrapper for get_option('stylesheet');, except that it also applies a 'stylesheet' filter.

function get_stylesheet() {
/**
 * Filters the name of current stylesheet.
 *
 * @since 1.5.0
 *
 * @param string $stylesheet Name of the current stylesheet.
 */
return apply_filters( 'stylesheet', get_option( 'stylesheet' ) );
}

I'm not sure what the 'stylesheet' filter does. Looks like it might have something to do with the customizer.

In the vast majority of cases, these three functions would do the same thing, but get_stylesheet(); seems like the safest bet.