The sidebar is a versatile component designed to organize your site's content and navigation. It offers a structured overview of your site's layout, making it easier for users to explore and locate information.
If you hit any issues, make sure you check out the installation guide here for more information.
Composed components
When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.
The Sidebar comes packed with several components to enhance functionality and provide a seamless experience.
ButtonButtons play a crucial role in functionality, whether for submitting a form or navigating to another page.
SheetA slide-in panel for presenting additional content without disrupting the main screen.
TooltipA brief, informative message that appears when hovering or focusing on an element.
BadgeA small, attention-grabbing UI element used to display notifications, status indicators, or counts in a compact format.
Manual installation
Make sure you also install the composed components and the required packages for the component to function properly.
Anatomy
CSS Variables
The sidebar just need one base color to work, the accent will generate from the base and the primary color just taking from the primary color you have. Make sure you have set evertyhing up, or hover into theme page to see the bunch of colors you can get. Too lazy? just copy the default color below to your stylesheet.
Not sure if it's your style, but it's a great starting point. If you’d like to tweak the colors, check out the theme customization page for more options.
Intent
The sidebar comes in three variations: "sidebar", "float", and "inset". By default, the variation is set to "sidebar".
Sidebar
The default variation is a traditional sidebar often used for navigation. Preview.
<Sidebar intent="sidebar" />
Inset
The inset variation adds padding to the main content for a visually distinct layout. Explore the demo to see it in action, or switch to full-screen mode for a better view. Preview.
<Sidebar intent="inset" />
Float
The float variation introduces an inner border within the sidebar, while the wrapper includes padding around the content. Preview
<Sidebar intent="float" />
Collapsible
The sidebar can be made collapsible by using the collapsible prop in the SidebarProvider. The default collapsible behavior is "hidden".
Hidden
When toggled, the sidebar hides completely from view. Preview
<Sidebar collapsible="hidden" />
Dock
When toggled, the sidebar docks to a minimal state, showing only icons. Hovering over an icon reveals a tooltip with additional information. Preview
<Sidebar intent="dock" />
Default Open
The sidebar’s initial state can be controlled using the defaultOpen prop. For example, you can set defaultOpen to false and keep the sidebar docked.
The sidebar has two sides, left and right. You can set the side of the sidebar by using the side prop. Preview
<Sidebar side='left | right'/>
Loading source code...
Put Anything
You can put anything you want in it. You can use the SidebarContent component to wrap your content. Let's try to add a range-calendar and search-field to the sidebar. Preview
Loading source code...
Remember state
To persist the sidebar’s state across sessions, wrap your layout with the SidebarProvider component. It stores the sidebar’s state in a cookie and restores it when the user revisits the page.
import { cookies } from "next/headers"export default async function Layout({ children }: Readonly<{ children: React.ReactNode }>) { const cookieStore = await cookies() const sidebarState = cookieStore.get("sidebar_state") let defaultOpen = true if (sidebarState) { defaultOpen = sidebarState.value === "true" } return ( <SidebarProvider defaultOpen={defaultOpen}>