Skip to content

feat(react): follow a data-theme ancestor in React chat - #1640

Open
blove wants to merge 1 commit into
mainfrom
blove/react-chat-data-theme
Open

blove wants to merge 1 commit into
mainfrom
blove/react-chat-data-theme

Conversation

@blove

@blove blove commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Angular chat honors [data-theme="dark|light"] and [data-threadplane-chat-theme="dark|light"] on any ancestor, forcing that scheme over prefers-color-scheme (libs/chat/src/lib/styles/chat-tokens.ts). React chat only read prefers-color-scheme, so an app theme toggle never reached it.

  • libs/react/src/chat/styles.css: the attributes set an inherited --tp-chat-theme-scheme; .tp-chat uses color-scheme: var(--tp-chat-color-scheme, var(--tp-chat-theme-scheme, light dark)). Precedence: explicit --tp-chat-color-scheme, then nearest attribute (dark declared last, as in Angular), then the system. All chat tokens use light-dark(), so they flip with it.
  • libs/react/src/a2ui/styles.css: the prefers-color-scheme block gets matching light and dark attribute rules (same selectors, after the media query; theme files still outrank them). Debug styles have no scheme media queries.
  • Specs assert the selectors, ordering and precedence on the parsed CSS; README and the theming guide document it.

Verification

  • nx run-many -t test lint type-tests -p react: lint and type-tests pass; the new and changed specs (theme-tokens, themes) pass (27 tests). One earlier failure in the token-mapping guard was fixed by exempting the internal --tp-chat-theme-scheme.
  • Website docs-content-rules spec: 10 passed (no contractions). A full website vitest run in this worktree showed environment failures (symlinked node_modules, parallel load); not attributable to this change.
  • inventory.mjs --check --drift warn: valid. No new exports or files, so no verify-packages changes.

🤖 Generated with Claude Code

Angular chat forces light or dark from [data-theme] or
[data-threadplane-chat-theme] on any ancestor. React chat only read
prefers-color-scheme, so an app theme toggle never reached it. The chat
color-scheme now reads an inherited scheme set by those attributes (nearest
wins, dark last on one element), and an explicit --tp-chat-color-scheme still
wins. The A2UI surface stylesheet, which used a prefers-color-scheme block,
follows the same attributes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@blove
blove enabled auto-merge November 17, 2026 23:46

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant