Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I create a Logout link (with icon) at the footer of the sidebar ? (in React) #419

Open
axilaris opened this issue Apr 6, 2024 · 3 comments

Comments

@axilaris
Copy link

axilaris commented Apr 6, 2024

How do I create a Logout link (with icon) properly at the footer of the sidebar ? (in React). I would like it to be able to disappear the text when sidebar collapse while the icon remains.

I tried the following:

      <CSidebarFooter className="border-top d-none d-lg-flex">
        
      <CNavItem customClassName="nav-icon">
        <CNavLink to='/logout'>
          <CIcon icon={cilAccountLogout} className="me-2" />
          Logout
        </CNavLink>
      </CNavItem>
  
        <CSidebarToggler
          onClick={() => dispatch({ type: 'set', sidebarUnfoldable: !unfoldable })}
        />
      </CSidebarFooter>

But if you check out the screenshots. There is a dot and when the sidebar is contracted, the word "Logout" doesnt disappear.

Screenshot 2024-04-06 at 8 28 32 AM

WhatsApp Image 2024-04-06 at 8 28 14 AM

@mrholek
Copy link
Member

mrholek commented Apr 9, 2024

@axilaris <CNavItem> should be wrapped in <CSidebarNav>

@axilaris
Copy link
Author

@mrholek
Thanks a lot. it manage to disappear the icon and text altogether when collapse.

but i actually want the icon to appear when collapse. what can be done ?

      <CSidebarNav>
        <CNavItem customClassName="nav-icon">
          <CNavLink to='/logout'>
            <CIcon icon={cilAccountLogout} className="me-2" />
            Logout
          </CNavLink>
        </CNavItem>
      </CSidebarNav>

another way i thought is this, but this disappear the icon but not the text. its the other way round that i want. icon should be maintain when collapse.


      <CSidebarFooter style={{ cursor: 'pointer' }}>               

            <CIcon icon={cilAccountLogout} height={20} onClick={handleLogout}/>      
            <div onClick={handleLogout} style={{fontSize: 15 }}> Logout</div>  


        <CSidebarToggler
          onClick={() => dispatch({ type: 'set', sidebarUnfoldable: !unfoldable })}
        />        
      </CSidebarFooter>

@axilaris
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants