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
| Prop | Type | Default | What 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? }[] | sample | The conversations. `at` is an ISO time; pinned ones sit at the top. An empty list shows a way to start. |
today | string ('YYYY-MM-DD') | sample | The day the groups count from, so the server and the browser group the same way. |
activeId | string | sample | The 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. |
loading | boolean | false | Shows the shape of the list while it loads. |
error | boolean | string | false | The list did not load: a message (or this text) and Try again, which calls onRetry. |
labels | object | — | Replaces any built-in text (see copy.js), such as title, search, groups or undo. |
className | string | — | 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.