Skip to content

Sidebar

Download .md

The sidebar is the main navigation of a Sosialoka dashboard, on the left of every page.

  • Use it for the 4 to 8 main sections of a product.
  • Group related items under a label when there are more than six.
  • Put page-level actions in the page, not in the sidebar.
React
Vue
1234
  1. 1Product logo
  2. 2Active item
  3. 3Search card
  4. 4Content

This is the sidebar of the dashboard shell (Alternative A): a white panel (sidebar) 16rem wide, with icon and label items on radius-md. The active item uses sidebar-accent with sidebar-accent-foreground text, the product’s soft tint. On small screens it becomes a sheet that slides in.

  • collapsible="offcanvas" (default): slides away on small screens.
  • collapsible="icon": collapses to icons.
  • collapsible="none": always shown, as in the preview.
React Vue Flutter Type Default Use
SidebarProvider SidebarProvider none element none Holds the open state; wraps the layout.
collapsible collapsible none see Variants offcanvas How it collapses.
SidebarMenuButton isActive SidebarMenuButton :is-active backgroundColor from sidebar-accent boolean false Marks the current section.
SidebarMenuButton render SidebarMenuButton as-child onPressed element button Renders the item as a link.
import { BarChart3Icon, DiscIcon, FileTextIcon, HomeIcon, SettingsIcon } from "lucide-react"
import {
Sidebar,
SidebarContent,
SidebarGroup,
SidebarGroupContent,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
SidebarProvider,
} from "@/components/ui/sidebar"
const items = [
{ title: "Dasbor", icon: HomeIcon, active: true },
{ title: "Rilis", icon: DiscIcon },
{ title: "Royalti", icon: BarChart3Icon },
{ title: "Dokumen", icon: FileTextIcon },
{ title: "Pengaturan", icon: SettingsIcon },
]
export default function SidebarDemo() {
return (
<SidebarProvider className="min-h-0 w-auto">
<div className="h-96 overflow-hidden rounded-lg border border-border">
<Sidebar collapsible="none">
<SidebarContent>
<SidebarGroup>
<SidebarGroupContent>
<SidebarMenu>
{items.map((item) => (
<SidebarMenuItem key={item.title}>
<SidebarMenuButton
isActive={item.active}
render={<a href="#" aria-current={item.active ? "page" : undefined} />}
>
<item.icon />
<span>{item.title}</span>
</SidebarMenuButton>
</SidebarMenuItem>
))}
</SidebarMenu>
</SidebarGroupContent>
</SidebarGroup>
</SidebarContent>
</Sidebar>
</div>
</SidebarProvider>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/sidebar.json

It also installs the Sosialoka sheet, separator, skeleton, tooltip, input and button.

  • Render items as links, and set aria-current="page" on the active one.
  • The collapse button needs an aria-label; the sidebar can be toggled with ⌘B or Ctrl+B.