Category nicename inside loop in wordpress

You can use get_the_category inside the loop to get the category/ies a post is assigned to. To get a list of available member variables available, see get_categories.

I would suggest to target the first category only, which will also be the parent category if the post is assigned to only one parent and some of the parent’s child categories. Here is an example to get the first category assigned to a post’s nicename

$category = get_the_category(); 
$post_cat = $category[0]->category_nicename;

You can now use $post_cat as your class. Just remember to add this code before this line

echo <div class="btn category-nicename"> 

Just a word of advice here, do not abuse echo. Use php tags where necessary to avoid using the unnecessary use of echo. BTW, your syntax is wrong

echo <div class="btn category-nicename">

should be

echo '<div class="btn category-nicename">';

if you are going to use echo

EDIT

From your comment above ^^, you need to get the current category’s nice name. You can get the current category with get_query_var( 'cat') and from that you can get the nice name

$category = get_query_var( 'cat' );
$post_cat = $category->category_nicename;

As above, just use $post_cat in your class. I hope this answers your question