Copy to clipboard
Main content area
Installation
Copy to clipboard
npx bearnie add sidebar
npx bearnie add sidebar
bunx bearnie add sidebar
bunx bearnie add sidebar
pnpm dlx bearnie add sidebar
pnpm dlx bearnie add sidebar
yarn dlx bearnie add sidebar
yarn dlx bearnie add sidebar
Copy to clipboard
import Sidebar from "@/components/ui/sidebar/Sidebar.astro";
import SidebarHeader from "@/components/ui/sidebar/SidebarHeader.astro";
import SidebarContent from "@/components/ui/sidebar/SidebarContent.astro";
import SidebarFooter from "@/components/ui/sidebar/SidebarFooter.astro";
import SidebarGroup from "@/components/ui/sidebar/SidebarGroup.astro";
import SidebarGroupLabel from "@/components/ui/sidebar/SidebarGroupLabel.astro";
import SidebarMenu from "@/components/ui/sidebar/SidebarMenu.astro";
import SidebarMenuItem from "@/components/ui/sidebar/SidebarMenuItem.astro";
import SidebarMenuButton from "@/components/ui/sidebar/SidebarMenuButton.astro";
import SidebarTrigger from "@/components/ui/sidebar/SidebarTrigger.astro";
import SidebarSeparator from "@/components/ui/sidebar/SidebarSeparator.astro";
Usage
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarGroup,
SidebarGroupLabel,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
} from "@/components/ui/sidebar"
<Sidebar>
<SidebarHeader>
<span>Logo</span>
</SidebarHeader>
<SidebarContent>
<SidebarGroup>
<SidebarGroupLabel>Menu</SidebarGroupLabel>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton href="/">
<HomeIcon />
<span>Home</span>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarGroup>
</SidebarContent>
<SidebarFooter>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton href="/settings">
<SettingsIcon />
<span>Settings</span>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarFooter>
</Sidebar>
Examples
With trigger
Use SidebarTrigger to toggle the sidebar.
Copy to clipboard
Multiple groups
Copy to clipboard
Content
Structure
Sidebar- Main container with collapsible stateSidebarHeader- Sticky header sectionSidebarContent- Scrollable content areaSidebarFooter- Sticky footer sectionSidebarGroup- Groups related menu itemsSidebarGroupLabel- Label for a groupSidebarMenu- Menu container (ul)SidebarMenuItem- Menu item wrapper (li)SidebarMenuButton- Clickable menu button/linkSidebarTrigger- Toggle buttonSidebarSeparator- Visual divider
Props
Sidebar
| Prop | Type | Default | Description |
|---|---|---|---|
| side | ”left” | “right" | "left” | Side of the screen |
| collapsible | boolean | true | Whether sidebar can collapse |
| defaultOpen | boolean | true | Initial open state |
| class | string | - | Additional CSS classes |
SidebarMenuButton
| Prop | Type | Default | Description |
|---|---|---|---|
| href | string | - | Link URL (renders as anchor) |
| isActive | boolean | false | Active state styling |
| class | string | - | Additional CSS classes |
SidebarTrigger
| Prop | Type | Default | Description |
|---|---|---|---|
| for | string | - | ID of sidebar to target |
| class | string | - | Additional CSS classes |
Theming
The sidebar uses dedicated CSS variables for theming:
:root {
--sidebar: oklch(0.985 0 0);
--sidebar-foreground: oklch(0.145 0 0);
--sidebar-accent: oklch(0.97 0 0);
--sidebar-accent-foreground: oklch(0.205 0 0);
--sidebar-border: oklch(0.922 0 0);
--sidebar-ring: oklch(0.708 0 0);
}
.dark {
--sidebar: oklch(0.205 0 0);
--sidebar-foreground: oklch(0.985 0 0);
--sidebar-accent: oklch(0.269 0 0);
--sidebar-accent-foreground: oklch(0.985 0 0);
--sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.439 0 0);
}