Skip to content

Commit 96db332

Browse files
authored
docs: explain chat token bridge (#790)
1 parent 5ab848f commit 96db332

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

apps/website/content/docs/chat/guides/theming.mdx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,35 @@ Import `@threadplane/chat/chat.css` in your global styles to get a `:root`-level
9797
}
9898
```
9999

100+
### Bridge from your design system
101+
102+
If your app already has design-system tokens, keep those tokens as the source of truth and map them into the chat public API. This gives your app a stable `--tplane-chat-*` control surface without coupling chat internals to your design-system namespace.
103+
104+
```css
105+
:root {
106+
/* App-owned design tokens */
107+
--ds-canvas: #ffffff;
108+
--ds-surface: #f8fafc;
109+
--ds-border: #e2e8f0;
110+
--ds-text-primary: #0f172a;
111+
--ds-text-muted: #64748b;
112+
--ds-accent: #2563eb;
113+
--ds-font-sans: Inter, system-ui, sans-serif;
114+
115+
/* Chat-owned public API */
116+
--tplane-chat-bg: var(--ds-canvas);
117+
--tplane-chat-surface: var(--ds-surface);
118+
--tplane-chat-surface-alt: var(--ds-surface);
119+
--tplane-chat-separator: var(--ds-border);
120+
--tplane-chat-text: var(--ds-text-primary);
121+
--tplane-chat-text-muted: var(--ds-text-muted);
122+
--tplane-chat-primary: var(--ds-accent);
123+
--tplane-chat-font-family: var(--ds-font-sans);
124+
}
125+
```
126+
127+
Use the `--tplane-chat-*` names at chat boundaries and custom chat-adjacent views. Use your app tokens everywhere else. The bridge is useful because chat token names describe component semantics (`primary`, `surface-alt`, `separator`, `radius-bubble`) while your design-system tokens can stay product-wide and evolve independently.
128+
100129
## Brand Color Example
101130

102131
```css

libs/chat/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,41 @@ Without `katex` installed, or without the stylesheet, math degrades gracefully
231231

232232
### Theming
233233

234+
Chat compositions and primitives expose a `--tplane-chat-*` CSS variable API for colors, typography, spacing, radii, and z-index layers. Override those variables on `:root`, on the `<chat>` host, or on any ancestor:
235+
236+
```css
237+
:root {
238+
--tplane-chat-primary: #2563eb;
239+
--tplane-chat-on-primary: #ffffff;
240+
--tplane-chat-radius-bubble: 12px;
241+
}
242+
```
243+
244+
If your app already has design-system tokens, keep them as the source of truth and bridge them into the chat API:
245+
246+
```css
247+
:root {
248+
--ds-canvas: #ffffff;
249+
--ds-surface: #f8fafc;
250+
--ds-border: #e2e8f0;
251+
--ds-text-primary: #0f172a;
252+
--ds-text-muted: #64748b;
253+
--ds-accent: #2563eb;
254+
--ds-font-sans: Inter, system-ui, sans-serif;
255+
256+
--tplane-chat-bg: var(--ds-canvas);
257+
--tplane-chat-surface: var(--ds-surface);
258+
--tplane-chat-surface-alt: var(--ds-surface);
259+
--tplane-chat-separator: var(--ds-border);
260+
--tplane-chat-text: var(--ds-text-primary);
261+
--tplane-chat-text-muted: var(--ds-text-muted);
262+
--tplane-chat-primary: var(--ds-accent);
263+
--tplane-chat-font-family: var(--ds-font-sans);
264+
}
265+
```
266+
267+
Use app tokens for app layout and `--tplane-chat-*` tokens at chat boundaries or custom chat-adjacent views. That keeps chat's public theming surface stable even if your app design-system token names change.
268+
234269
`<a2ui-surface>` declares ~50 `--a2ui-*` CSS custom properties at `:host` with dark-theme defaults covering color, spacing, typography, shape radius, focus ring, motion, and elevation. Catalog components consume them via `var(--a2ui-*)`.
235270

236271
**Built-in presets** — import one in your global stylesheet:

0 commit comments

Comments
 (0)