Skip to content
ShellChat headerMenu

Chat header

The bar above a thread: a title you rename in place, the model, a Temporary badge, Share and a More menu, plus the sidebar toggle on mobile.

Editable title, model, Temporary badge, Share, More and the sidebar toggle.

Installation

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

Usage

tsx
import { ChatHeader } from "@/components/ui/chatcn/chat-header"
import { MenuItem } from "@/components/ui/chatcn/menu"
import { ModelPicker } from "@/components/ui/chatcn/model-picker"

<ChatHeader
  title={thread.title}
  onTitleChange={(title) => rename(thread.id, title)}
  model={<ModelPicker models={models} value={model} onValueChange={setModel} size="sm" />}
  onShare={share}
  menu={<MenuItem onClick={archive}>Archive</MenuItem>}
/>

Pass it to Chatbot as header, or put it at the top of the thread in a ChatLayout. On mobile it shows the sidebar toggle and, with onNewChat, a New chat button. Set bordered once the thread scrolls under it.

Props

PropTypeNotes
title, placeholderstringPlaceholder defaults to New chat
onTitleChange(title) => voidMakes the title editable
editablebooleanForce editing on or off
modelReactNodeUsually a small ModelPicker. Hidden below 640 px
temporary, temporaryDescriptionThe Temporary badge and its tooltip
onShare() => voidLabelled on desktop, icon-only on phones
menuReactNodeMenuItems for More
actionsReactNodeExtra controls before Share
sidebarToggle"auto" | booleanauto shows it on mobile in a ChatLayout
onSidebarToggle() => voidFor use outside a ChatLayout
onNewChat() => voidNew chat next to the toggle
borderedbooleanBottom hairline

Keyboard

KeyAction
Enter on the titleRename
Enter in the fieldSave
Esc in the fieldCancel

Accessibility

  • The title is the page h1. As a button it is named Rename chat with the title.
  • The Temporary badge is focusable so keyboard users can read its tooltip.
  • The sidebar toggle carries aria-controls, aria-expanded and aria-keyshortcuts.

Motion

  • A new title fades in once over 200 ms. The bottom hairline fades in over 150 ms.