Skip to content

Components

Sidebar

An app or docs sidebar that collapses to icons or slides away on desktop, opens as a sheet on phones and toggles with Ctrl or Cmd + B.

Customize
Loading preview…

Installation

Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.

pnpm dlx @ombelle-ui/cli@1.1.2 add sidebar

Adds components/ui/sidebar.tsx and installs react, @radix-ui/react-dialog, @radix-ui/react-collapsible, @radix-ui/react-slot, @radix-ui/react-tooltip, clsx, tailwind-merge, lucide-react with lifecycle scripts disabled. This is a client component.

In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.

Usage

example.tsx
import { Sidebar, SidebarContent, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider, SidebarRail, SidebarTrigger } from '@/components/ui/sidebar'
import { Box, FolderOpen, LayoutDashboard, Palette } from 'lucide-react'
const items = [{ href: '/', label: 'Overview', icon: LayoutDashboard }, { href: '/projects', label: 'Projects', icon: FolderOpen }, { href: '/presets', label: 'Presets', icon: Palette }, { href: '/components', label: 'Components', icon: Box }]
export function Example(){return <SidebarProvider><Sidebar collapsible="icon" label="Workspace"><SidebarHeader><strong>Ombelle</strong></SidebarHeader><SidebarContent><SidebarGroup><SidebarGroupLabel>Workspace</SidebarGroupLabel><SidebarGroupContent><SidebarMenu>{items.map((item, index) => <SidebarMenuItem key={item.href}><SidebarMenuButton href={item.href} isActive={index === 0} tooltip={item.label}><item.icon aria-hidden="true" /><span>{item.label}</span></SidebarMenuButton></SidebarMenuItem>)}</SidebarMenu></SidebarGroupContent></SidebarGroup></SidebarContent><SidebarRail /></Sidebar><SidebarInset><header><SidebarTrigger /></header></SidebarInset></SidebarProvider>}

API and states

API
SidebarProvider (open, defaultOpen, onOpenChange, mobileBreakpoint, shortcut), Sidebar (side, variant sidebar, floating or inset, collapsible offcanvas, icon or none, label), SidebarTrigger, SidebarRail, SidebarInset, SidebarHeader, SidebarContent, SidebarFooter, SidebarInput, SidebarGroup, SidebarGroupLabel, SidebarGroupAction, SidebarGroupContent, SidebarGroupCollapsible, SidebarGroupCollapsibleTrigger, SidebarGroupCollapsibleContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton (href, isActive, tooltip), SidebarMenuAction, SidebarMenuBadge, SidebarMenuSub, SidebarMenuSubItem, SidebarMenuSubButton, useSidebar
Minimum states
Expanded, collapsed to icons, slid away, phone sheet, current item, hover, focus, before hydration on a phone
Native basis
Radix Dialog, Tooltip and Collapsible; Base UI Dialog, Tooltip and Collapsible in the Base UI edition
Styles
Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.