Introducing PrimeReact v11-alpha 🎉Discover Now

Sidebar

Sidebar is a layout component for building application navigation with collapsible panels, multi-variant styling, and composable menu structures.

Navigation
  • 12
  • 3
Projects
Billing
preview

Installation#

npx shadcn@latest add @primereact/sidebar

Usage#

import {
    Sidebar,
    SidebarBody,
    SidebarContent,
    SidebarFooter,
    SidebarGroup,
    SidebarGroupContent,
    SidebarGroupLabel,
    SidebarHeader,
    SidebarInset,
    SidebarLayout,
    SidebarMenu,
    SidebarMenuButton,
    SidebarMenuItem,
    SidebarPanel,
    SidebarSpacer,
    SidebarTrigger
} from '@/components/ui/sidebar';
<SidebarLayout>
    <Sidebar id="main" collapsible="icon">
        <SidebarSpacer />
        <SidebarPanel>
            <SidebarBody>
                <SidebarHeader>...</SidebarHeader>
                <SidebarContent>
                    <SidebarGroup>
                        <SidebarGroupLabel>Navigation</SidebarGroupLabel>
                        <SidebarGroupContent>
                            <SidebarMenu>
                                <SidebarMenuItem>
                                    <SidebarMenuButton isActive>
                                        <HomeIcon />
                                        <span>Home</span>
                                    </SidebarMenuButton>
                                </SidebarMenuItem>
                            </SidebarMenu>
                        </SidebarGroupContent>
                    </SidebarGroup>
                </SidebarContent>
                <SidebarFooter>...</SidebarFooter>
            </SidebarBody>
        </SidebarPanel>
    </Sidebar>
    <SidebarInset>
        <SidebarTrigger />
        <main>Content</main>
    </SidebarInset>
</SidebarLayout>

Examples#

Variants#

Use the variant and collapsible props to control the sidebar appearance and collapse behavior.

Navigation
  • 12
  • 3
Projects
Billing
variants-demo

Responsive#

Use useIsMobile hook to switch between desktop and mobile layouts. On mobile, the sidebar becomes offcanvas with overlay and backdrop.

Menu
  • 3
DashboardDesktop
responsive-demo

Dual Sidebar#

Navigation
  • 5
Projects
Dashboard
Weekly metrics overview
Show me this week's metrics

Here are your key metrics for this week:

  • Page views12,482
  • New users342
  • Bounce rate34%
dual-demo

Multi Sidebar#

Settings
Configuration
Integrations
Billing
Table Editor/ users
multi-demo

Nested Menu#

Recursive menu structure with deeply nested sub-items using Sidebar.MenuSub and a recursive render function.

Files
File Manager

Q1 Report

Documents > Work > Projects > Q1 Report

nested-demo

Chat Application#

Today
Yesterday
Previous 7 days
Previous 30 days
chat-demo

API#

Sub-Components#

See Primitive API for SidebarLayout, SidebarRoot, SidebarSpacer, SidebarPanel, SidebarBody, SidebarHeader, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarMenuAction, SidebarMenuBadge, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton, SidebarTrigger, SidebarRail, SidebarInset, SidebarBackdrop component documentation.

Hooks#

See Headless API for useSidebar, useSidebarLayout, useSidebarMenuItem hook documentation.

Accessibility#

See Sidebar Primitive for WAI-ARIA compliance details and keyboard support.