Chakra Components
Sidebar

Chakra UI Sidebar

The sidebar is used in our dashboard layout and it takes on several props, since it offers different functionalities like displaying the profile picture of the user, logout button and more. Here is an example of the Navbar component :

/components/layout/index.tsx
import Navbar from '@/components/navbar/NavbarAdmin';
import { routes } from '@/components/routes'; 
import { getActiveRoute } from '@/utils/navigation';
import React from 'react'; 
 
const DashboardLayout: React.FC<Props> = (props: Props) => {
  const pathname = usePathname();
  const [open, setOpen] = React.useState(false);
 
  return (
    ..................... 
      <Sidebar
          routes={routes}
          session={props.session}
          userDetails={props.userDetails}
          user={props.session?.user} 
          subscription={props.subscription}
          open={open}
          setOpen={() => setOpen(!open)}
        />  
      .................... 
  );
};
 
export default DashboardLayout;
  • routes - passes and object that makes the routes automatically generate
  • onOpen - function that opens/closes the sidebar on the mobile screen
  • open - boolean that dictates if the sidebar on the mobile screen is opened or not
  • userDetails - object that includes user characteristics like name and profile picture
  • user - points to a specific user
  • subscription - object with the subscription owned by the user, doesn't pass anything if the subscription is non-existent
  • session - gives the sidebar user session details

Sidebar