I am trying to figure out how to add css class to body tag programmatically using Magento 2 framework
You can add a class to the body from a block by overriding the _prepareLayout
method:
public function _prepareLayout(){
$this->pageConfig->addBodyClass('my-class');
return parent::_prepareLayout();
}