How to add custom HTML class to "Sign Out" button in magento2

enter image description here


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");
  • Thank you works – Jaisa Apr 10 '20 at 14:07

May be help you . /Magento_theme/templates/html/header.phtml

$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>
<?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>
<?php endif;?>

And more information link :-


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.