How to add custom HTML class to "Sign Out" button in magento2
2 Answers
You can add class using jQuery also. Create one custom JS file and include it in section. Add below code in your JS file:
require(['jquery'], function ($) {
$(document).ready(function () {
$(".authorization-link a").addClass("sl-custom-class");
});
});
May be help you . /Magento_theme/templates/html/header.phtml
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->create('Magento\Customer\Model\Session');
if($customerSession->isLoggedIn()) : ?>
<span class="header_account_link_list logout">
<a class= "header_account_link" href="<?php echo $this->getUrl("customer/account/logout");?>"><?php echo __('Logout')?></a>
</span>
<?php else: ?>
<span class="header_account_link_list login">
<a class= "header_account_link" href="<?php echo $this->getUrl("customer/account/login");?>"><?php echo __('Sign in')?></a>
</span>
<?php endif;?>
And more information link :-