|
| 1 | +# Chat Customization (CSS) |
| 2 | + |
| 3 | +## What This Demo Shows |
| 4 | + |
| 5 | +How far you can push `CopilotChat` with CSS alone — no slot overrides, no |
| 6 | +component swaps, no React. The default look is rounded, system-sans, and |
| 7 | +minimal-light. This demo replaces it with **HALCYON**, a warm-paper |
| 8 | +editorial brand: cream parchment surface, sharp 90° corners, copper-ember |
| 9 | +accents, an italic display serif for big headings, a Fraunces serif voice |
| 10 | +for the assistant, and JetBrains Mono dispatch lines for the user. |
| 11 | + |
| 12 | +The point: a team can take CopilotChat off the shelf and skin it to match |
| 13 | +their own brand without ever opening a component file. |
| 14 | + |
| 15 | +## How it works |
| 16 | + |
| 17 | +Two layers do the work: |
| 18 | + |
| 19 | +1. **v2 token overrides on `[data-copilotkit]`** — `--background`, |
| 20 | + `--foreground`, `--primary`, `--muted`, `--border`, `--ring`, `--radius`, |
| 21 | + etc. Recolors every Tailwind utility (`cpk:bg-muted`, |
| 22 | + `cpk:text-foreground`, …) the runtime renders. |
| 23 | +2. **Class-targeted styling** — `.copilotKitChat`, `.copilotKitMessages`, |
| 24 | + `.copilotKitMessage.copilotKitUserMessage`, |
| 25 | + `.copilotKitMessage.copilotKitAssistantMessage`, `.copilotKitInput`, the |
| 26 | + welcome screen, suggestions, scrollbar. |
| 27 | + |
| 28 | +Every selector is namespaced under `.chat-css-demo-scope`, so the theme |
| 29 | +cannot leak into the rest of the showcase. |
| 30 | + |
| 31 | +## How to Interact |
| 32 | + |
| 33 | +Type any prompt and watch the conversation render in the HALCYON voice: |
| 34 | + |
| 35 | +- `"Say hi"` |
| 36 | +- `"Write a one-paragraph product memo about quarterly OKRs"` |
| 37 | +- `"Show me a Python snippet for retry with exponential backoff"` |
| 38 | +- `"Quote a famous business strategist on focus"` |
| 39 | + |
| 40 | +You'll see: |
| 41 | + |
| 42 | +- The user line render as a mono CLI dispatch with an ember `→` marker |
| 43 | +- The assistant respond in serif body type with editorial spacing, an |
| 44 | + ember left rule, and a dark code-card for code blocks |
| 45 | +- The composer pill flatten to a sharp card with an ember focus ring and |
| 46 | + a square copper send button |
| 47 | + |
| 48 | +## Aesthetic Notes |
| 49 | + |
| 50 | +- **Surface** — warm parchment (`#F4EFE6`) with a single ambient ember glow |
| 51 | + in the top-left and a barely-perceptible paper-grain noise via inline |
| 52 | + SVG |
| 53 | +- **Masthead** — a centered mono label pinned just under the top edge of |
| 54 | + the chat surface (`CopilotChat · Customized with CSS`) |
| 55 | +- **Typography** — Instrument Serif (display, italic), Fraunces (assistant |
| 56 | + body), Inter Tight (UI), JetBrains Mono (user dispatch + metadata + |
| 57 | + suggestions) |
| 58 | +- **Accent** — deep copper ember (`#C44A1F`), used only on the user prompt |
| 59 | + marker, the assistant left rule, the send button, and focus rings — |
| 60 | + sparingly, so it actually reads as signal |
| 61 | +- **Geometry** — sharp 90° corners everywhere (radius is overridden to |
| 62 | + `0px`), opposite of the default rounded pills |
| 63 | + |
| 64 | +## Technical Details |
| 65 | + |
| 66 | +- `<CopilotKit>` wires `runtimeUrl="/api/copilotkit"` and |
| 67 | + `agent="chat-customization-css"` (backed by the shared simple chat |
| 68 | + agent in `src/agents/shared_chat.py`) |
| 69 | +- `<CopilotChat>` is wrapped in `<div className="chat-css-demo-scope">`; |
| 70 | + the theme is applied by `import "./theme.css"` at the top of the page |
| 71 | +- `theme.css` first overrides the v2 token variables on `[data-copilotkit]` |
| 72 | + (so Tailwind utilities recolor automatically), then layers |
| 73 | + class-targeted rules on top for the editorial details that CSS |
| 74 | + variables alone can't express |
| 75 | +- Fonts load from Google Fonts via `@import` at the top of `theme.css` |
| 76 | + so the demo is self-contained — copy the file into another project and |
| 77 | + the theme works end-to-end |
| 78 | +- Reach for slots (see `chat-slots`) when you need to change _what_ a |
| 79 | + piece renders, not just how it looks; reach for CSS — like this demo — |
| 80 | + when the default structure is fine and you only need a different |
| 81 | + visual identity |
0 commit comments