Skip to content

feat(examples-chat): A2UI Theme palette dropdown (Pass 4)#236

Merged
blove merged 1 commit into
mainfrom
claude/examples-chat-theme-dropdown
May 10, 2026
Merged

feat(examples-chat): A2UI Theme palette dropdown (Pass 4)#236
blove merged 1 commit into
mainfrom
claude/examples-chat-theme-dropdown

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 10, 2026

Summary

Pass 4 of the A2UI theming track — a demo-side palette dropdown that lets users switch the four shipped theme presets at runtime without editing CSS. Lives alongside Model / Effort / Gen UI in the existing palette.

Behavior

  • 4 options: Default dark / Default light / Material dark / Material light
  • Default `default-dark` (lib's `:host` defaults active)
  • Selection persisted via `palette-persistence` under key `theme`
  • Switching the dropdown updates `<html data-theme="...">` immediately; global stylesheet's `:root[data-theme=...]` selectors apply scoped `--a2ui-*` overrides

Implementation

Inline-themes-in-styles.css approach (vs. dynamic `` swap) sidesteps workspace-vs-published-path resolution complexity. Each theme's `:root[data-theme=...]` override block lives in `examples/chat/angular/src/styles.css`, mirroring the content of `libs/chat/src/themes/*.css` from PR #235.

  • `demo-shell`: `theme` signal + `effect()` reflecting onto ``
  • `control-palette`: `theme` + `themeOptions` inputs, `themeChange` output, new `` in template `palette-persistence`: `theme` key added to `PaletteState` Composition The agent's `beginRendering.styles.primaryColor` still wins per surface (host inline-style binding, highest specificity). Consumer-chosen theme + agent-chosen primary color compose cleanly: theme decides the palette baseline, agent can per-surface tweak the primary color. Test plan [x] `nx run-many -t test,lint,build -p examples-chat-angular` — all green [x] Live verified in Chrome: dropdown lists 4 options correctly; switching to Material dark updates `--a2ui-primary` computed style on `document.documentElement` to `#D0BCFF`; switching to Material light updates to `#6750A4`; `data-theme` attribute on `` updates synchronously 🤖 Generated with Claude Code

Adds a 6th palette dropdown that switches A2UI theme presets at
runtime by toggling `data-theme` on the document root. The global
stylesheet keys scoped `--a2ui-*` overrides off this attribute.

Four presets, mirroring the lib-side files shipped in PR #235:
- Default dark   (lib's :host defaults; data-theme attr set but no
                  override block needed — the unset state)
- Default light  (neutral light, blue accent, off-white surface)
- Material dark  (M3 purple primary on dark surface)
- Material light (M3 purple primary on near-white surface)

Inline-themes-in-styles.css approach (vs. dynamic <link> swap)
sidesteps the workspace-vs-published-path resolution complexity:
each theme's :root override block lives in
examples/chat/angular/src/styles.css gated by `data-theme="..."`
attribute selector. Mirrors content from libs/chat/src/themes/*.css.

Wiring:
- demo-shell: `theme` signal (default 'default-dark', persisted via
  palette-persistence under key 'theme'); `effect()` reflects current
  signal value onto `<html data-theme>` so the global stylesheet's
  `:root[data-theme=...]` rules activate. Initial mount reads from
  persistence and the effect immediately syncs the attribute.
- control-palette: new `theme` + `themeOptions` inputs and
  `themeChange` output; new `<select>` next to Gen UI.
- palette-persistence: `theme` added to PaletteState type.

Verified live: switching the dropdown updates --a2ui-primary
computed style on document root in real time:
- default-dark: lib :host default (--a2ui-primary inherited from
                surface component, computed at root = empty/inherit)
- material-dark: --a2ui-primary = #D0BCFF (M3 purple)
- material-light: --a2ui-primary = #6750A4 (M3 light purple)
- data-theme attribute on <html> updates synchronously

The agent's beginRendering.styles.primaryColor still wins per surface
(host inline-style binding, highest specificity), so consumer-chosen
theme + agent-chosen primary color compose: theme decides palette
baseline, agent can per-surface override.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment May 10, 2026 4:06pm

Request Review

@blove blove merged commit 1699299 into main May 10, 2026
14 checks passed
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