Loading component…
Loading component…
What fills the model's context, as a field of cells – hover a part to light it up, remove files, and compact the conversation while its cells shimmer and clear
To reuse this local React demo, copy all files from the Code tab into the same folder, then import ContextWindow from ./context-window.
import { ContextWindow } from "@/components/ui/context-window";
export function SessionContext() {
return (
<ContextWindow
limit={200_000}
model="claude-sonnet-5-5"
parts={[
{ id: "system", label: "System prompt", tokens: 4200, locked: true },
{ id: "tools", label: "Tools", tokens: 12800 },
{
id: "files",
label: "Files",
items: [
{ id: "schema", label: "schema.prisma", tokens: 9400 },
{ id: "billing", label: "billing.ts", tokens: 21300 },
],
},
{ id: "chat", label: "Conversation", tokens: 108600, compact: true },
]}
/>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| parts | ContextPart[] | { id, label, tokens?, items?, locked?, compact?, color? } – they fill the field in this order | |
| limit | number | Size of the context window in tokens | |
| title | string | "Context window" | Heading of the card |
| model | string | Small tag in the head, e.g. the model name | |
| modelIcon | ReactNode | Logo in front of the model name, shown at 12px | |
| onRemoveItem | (partId: string, itemId: string) => void | Called when an item is removed. With it the card shows exactly what you pass; without it the removal lives inside the card | |
| onCompact | (partId: string) => void \| Promise<void> | Called when Compact is pressed; the cells shimmer until the promise settles. Without it the part shrinks on its own to its compact share | |
| action | { label: string; onClick: () => void } | A button on the tray, e.g. New chat | |
| warnAt | number | 0.8 | Share of the limit from which the percentage turns amber and the tray says how much is left; from 0.95 the window counts as full |
| cells | number | 216 | Number of cells in the field |
| columns | number | 36 | Cells per row |
| className | string | Extra class on the root |
Fills its container up to 360px. Below 310px the field puts fewer cells in a row so they stay readable, the model tag shortens and Compact keeps only its icon
Touch screens: taller rows and buttons
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"