Skip to Content
Skip to content

Sidebar

Neumorphic sidebar composed from the neu sheet, tooltip, input, separator, skeleton and button. The panel is its own ground; menu items are flat chips that tint on hover and sink, with an accent bar, when active.

Home

Installation

bunx --bun shadcn@latest add https://neu.beyondtheinnovation.com/r/neu-sidebar.json

Usage

import {
  Sidebar,
  SidebarContent,
  SidebarGroup,
  SidebarGroupLabel,
  SidebarInset,
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  SidebarProvider,
  SidebarTrigger,
} from "@/components/ui/neu/sidebar"
<SidebarProvider>
  <Sidebar>
    <SidebarContent>
      <SidebarGroup>
        <SidebarGroupLabel>Application</SidebarGroupLabel>
        <SidebarMenu>
          <SidebarMenuItem>
            <SidebarMenuButton isActive>Home</SidebarMenuButton>
          </SidebarMenuItem>
        </SidebarMenu>
      </SidebarGroup>
    </SidebarContent>
  </Sidebar>
  <SidebarInset>
    <SidebarTrigger />
  </SidebarInset>
</SidebarProvider>

Collapsible

collapsible="offcanvas" (the default) slides the panel away, "icon" shrinks it to an icon rail whose buttons show their tooltip, and "none" keeps it fixed. side and variant (sidebar, floating, inset) place and frame it.

<Sidebar side="right" variant="floating" collapsible="icon">
  <SidebarMenuButton tooltip="Home">
    <HomeIcon />
    <span>Home</span>
  </SidebarMenuButton>
</Sidebar>

Keyboard and persisted state

Cmd+B (Ctrl+B on Windows and Linux) toggles the sidebar. The provider writes the state to the sidebar_state cookie, so a server layout can render it the same way on the next load.

import { cookies } from "next/headers"

export default async function Layout({
  children,
}: {
  children: React.ReactNode
}) {
  const cookieStore = await cookies()
  const defaultOpen = cookieStore.get("sidebar_state")?.value !== "false"

  return <SidebarProvider defaultOpen={defaultOpen}>{children}</SidebarProvider>
}

useSidebar

Read or drive the sidebar from any component inside the provider.

const { state, open, setOpen, openMobile, isMobile, toggleSidebar } =
  useSidebar()

RTL

side is flow-relative: "left" is the inline start, so on an rtl page the default sidebar sits on the right edge, and its border, rail, cursors and mobile sheet follow it. Positions inside the panel are logical too, so actions, badges and sub menus follow the direction.

This differs from upstream shadcn, where side is physical. When porting, drop a side={dir === "rtl" ? "right" : "left"} and keep the default.

Pass dir when the direction is set below <html>, so the mobile sheet, which renders in a portal, opens from the right edge too.

<Sidebar dir="rtl">
  {/* ... */}
</Sidebar>

On this page