Skip to content
English

Usage

import { ChatHistory } from './ChatHistory.jsx'

export function TripSidebar({ chats, openChat }) {
  return (
    <ChatHistory
      locale="en"
      chats={chats}
      today={new Date().toISOString().slice(0, 10)}
      onSelect={openChat}
      onRename={(id, title) => fetch('/api/chats/' + id, { method: 'PATCH', body: JSON.stringify({ title }) })}
      onDelete={(id) => fetch('/api/chats/' + id, { method: 'DELETE' })}
    />
  )
}

Props

PropTypeDefaultWhat it does
locale'en' | 'zh-CN' | 'es' | 'ja''en'Language of the built-in text, the sample chats and the times.
chats{ id, title, at, pinned? }[]sampleThe conversations. `at` is an ISO time; pinned ones sit at the top. An empty list shows a way to start.
todaystring ('YYYY-MM-DD')sampleThe day the groups count from, so the server and the browser group the same way.
activeIdstringsampleThe open conversation, marked in the list.
onSelect(id) => void—Called when a conversation is opened.
onNew(chat) => void—Called with the new conversation added at the top of today.
onRename(id, title) => void—Called when a new name is saved (Enter or leaving the field). Escape keeps the old name.
onDelete(id) => void—Called once the few seconds to undo have passed, so an undone delete never reaches the server.
onPin(id, pinned) => void—Called when a conversation is pinned or unpinned.
loadingbooleanfalseShows the shape of the list while it loads.
errorboolean | stringfalseThe list did not load: a message (or this text) and Try again, which calls onRetry.
labelsobject—Replaces any built-in text (see copy.js), such as title, search, groups or undo.
classNamestring—Added to the root; other attributes go there too.

Add it to your project

Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the block together with the components it is built from.

ChatHistory.jsxchat-history.csscopy.jskit.jsxkit.cssui/base-button/ui/empty-state/ui/alert-banner/ui/text-input/ui/skeleton-shimmer/ui/dropdown-menu/tokens.cssREADME.md

The block, its stylesheet and text, the shared kit, the components it uses and tokens.css install together into one folder.