Skip to content
ShellProject switcherMenu

Project switcher

Switches the project a sidebar shows. Each project lists its knowledge files, instructions, sharing and indexing, so picking one says what context the next chat starts with.

Projects with their files and instructions, one still indexing, and the compact rail trigger.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/project-switcher.json

Usage

tsx
import { ProjectSwitcher } from "@/components/ui/chatcn/project-switcher"

<ProjectSwitcher
  projects={[
    { id: "web", name: "chatcn-web", filesCount: 14, hasInstructions: true },
    { id: "research", name: "Retrieval research", filesCount: 31, indexingCount: 3 },
  ]}
  value={projectId}
  onValueChange={setProjectId}
  onCreate={() => setCreating(true)}
/>

Put it in the sidebar header, and the compact version in railHeader. null means chats outside any project; turn that choice off with allowNone={false}.

Props

PropTypeNotes
projectsChatProject[]{ id, name, filesCount?, hasInstructions?, indexingCount?, shared?, disabled? }
value, defaultValue, onValueChangestring | nullControlled or uncontrolled
onCreate() => voidShows New project…
onManage(id) => voidShows Project settings… for the selected project
allowNone, noneLabelDefault true and No project
loading, disabledboolean
compactbooleanIcon-only trigger with a tooltip
side, alignMenu placement
open, defaultOpen, onOpenChangeMenu state

Keyboard

KeyAction
Enter, Space, ↓Open the menu
↑, ↓, typingMove and type ahead
EnterPick the project
EscClose

Accessibility

  • Projects are a radio group inside the menu, so the selected one is announced as checked.
  • Shared is a people mark with a spoken label, and indexing pairs a spinner with the file count.

Motion

  • The menu grows from the trigger over 180 ms. Opened from the keyboard, it appears instantly.