How to get configurable product’s used super_attribute details programmatically in Magento 2?

We can get the details of the used super attribute value for the configurable product. You will get the attribute value used in the configurable product using below example.

Let’s assume configurable product generated with color and size attributes. But how we can get details of super attribute value using programmatic that configurable product is made using color or size or color and size or any other attributes.

We can get Dynamically Configurable Product’s used Super attribute details by below code snippet.

Call function from template file,
$productId = 67;
$superAttribute = $this->getSuperAttributeData($productId);

Result will be,
[93] => color
[254] => size

Where 93,254 are attribute id and color,size are attribute code. Based on output  we can say configurable product is made using color and size super attirbute.