Sidebar Provider

Context provider for managing sidebar open/close state. Install Sidebar Provider from the VLLNT UI registry with the shadcn CLI.

Report a bug

Context provider for managing sidebar open/close state. Part of the navigation family in VLLNT UI, it ships as a machine-readable registry entry — copy the source directly into your app with the shadcn CLI and own it, no runtime dependency on a component library.

Preview

Switch between light and dark to inspect the embedded Storybook preview.

Installation

Add Sidebar Provider to your project with the shadcn CLI. The source lands in your codebase, ready to adapt:

pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/sidebar-provider.json

Source

"use client"; import { createContext, type ReactNode, use, useMemo, useState } from "react"; type SidebarContextType = { open: boolean; setOpen: (open: boolean) => void; }; const SidebarContext = createContext<SidebarContextType | undefined>(undefined); export function useSidebar() { const context = use(SidebarContext); if (!context) { throw new Error("useSidebar must be used within SidebarProvider"); } return context; } export function SidebarProvider({ children }: { children: ReactNode }) { const [open, setOpen] = useState(false); const value = useMemo(() => ({ open, setOpen }), [open]); return ( <SidebarContext.Provider value={value}>{children}</SidebarContext.Provider> ); }

Stories

Explore every variant and state in the interactive Storybook:

Preview

Switch between light and dark to inspect the embedded Storybook preview.

Dependencies

  • @vllnt/ui@^0.3.0