Getting Started
Dark Mode
Charts
Colors
Drag-and-drop
Forms
Utilities
Sidebar
Sidebar is a component that helps you organize your content and navigation.
Basic
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.
Installation
If you hit any issues, make sure you check out the installation guide here for more information.
Composed Components
Plug this component into the CLI, and it automatically loads all the included components. No need to add them individually.
The Sidebar comes packed with a variety of components to make it stand out.
Manual Installation
Sometimes, using the CLI is the way to go, so make sure you install the necessary dependencies for the components you want to use.
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.
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.
Float
The float
variation introduces an inner border within the sidebar, while the wrapper includes padding around the content. Preview
Fleet
The fleet
variation removes horizontal padding from the items. Check out how it works in action: Preview
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
Dock
When toggled, the sidebar docks to a minimal state, showing only icons. Hovering over an icon reveals a tooltip with additional information. Preview
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.
Sidebar Section
The sidebar section is a container for sidebar items. It accepts a title
prop, which will be displayed as a heading.
Sidebar Disclosure Group
If you need to collapse multiple items, you can use the SidebarDisclosureGroup
component. Preview
Menu
The sidebar supports menus, which can be used to display additional actions or options.
Badge
The sidebar supports badges, which can be used to indicate the number of unread messages, tasks, or other items. Preview
Separator
The sidebar supports separators, which can be used to separate sections or groups of items. Preview
The example previews will appear similar to the ones in the YouTube sidebar.
Tooltip
The sidebar supports tooltips, which can be used to display additional information when you're on docked mode.
Header
The sidebar supports headers, which can be used to display additional actions or options.
Footer
The sidebar supports footers, which can be used to display additional actions or options.
Side
The sidebar has two sides, left and right. You can set the side of the sidebar by using the side
prop. Preview
Put Anything
This is justd sidebar, so 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
Props
The sidebar supports the following props:
Sidebar
Property | Type | Default |
---|---|---|
intent | "default" | "float" | | "fleet" | "inset" | "default" |
collapsible | "hidden" | "dock" | "none" | "hidden" |
side | "left" | "right" | "left" |
closeButton | boolean | "true" |
SidebarContextProps
Property | Type |
---|---|
state | "expanded" | "collapsed" |
open | boolean |
setOpen | (open: boolean) => void |
isOpenOnMobile | boolean |
setIsOpenOnMobile | (open: boolean) => void |
isMobile | boolean |
toggleSidebar | () => void |
SidebarProviderProps
Property | Type | Default |
---|---|---|
defaultOpen | boolean | true |
isOpen | boolean | undefined |
onOpenChange | (open: boolean) => void | undefined |