Skip to content

fix(ui): alias --dg-color-* to --color-* so dark mode reaches utilities#37

Merged
lukeocodes merged 1 commit into
mainfrom
fix/dark-mode-utility-vars
May 11, 2026
Merged

fix(ui): alias --dg-color-* to --color-* so dark mode reaches utilities#37
lukeocodes merged 1 commit into
mainfrom
fix/dark-mode-utility-vars

Conversation

@lukeocodes
Copy link
Copy Markdown
Member

Summary

Dark-mode and external theme overrides don't reach Tailwind v4 utilities because prefix(dg) rewrites the utility-side var names. Adds an alias block so utilities resolve through the public --color-* API.

The bug

With prefix(dg) on the utilities import, Tailwind emits rules like:

.dg\:bg-card { background-color: var(--dg-color-card); }

The @theme block declares the public token as --color-card, and Tailwind auto-generates a paired --dg-color-card from it for the utility side. Two separate custom properties.

Every dark-mode block in this file only touches the unprefixed namespace:

[data-dg-agent][data-dg-scheme="dark"] {
  --color-card: #222228;   /* --dg-color-card never moves */
}

So in dark mode .dg:bg-card keeps resolving to the light-mode #f3f4f6 — visible as a near-white surface on mic-toggle, speaker-toggle, message bubbles, textarea border, etc. Outer container looks fine because it reads the unprefixed token directly in @layer base. Start button looks fine because the brand colour isn't overridden in dark mode, so light/dark resolve to the same green.

Fix

One [data-dg-agent] block aliases every prefixed theme token to its unprefixed counterpart. Anything that overrides --color-card — dark-mode block, prefers-color-scheme media, #demo-themed overrides downstream — now propagates to --dg-color-card through the cascade, and Tailwind utilities follow.

Single source of truth stays on the --color-* public API. Dark-mode override blocks stay one-namespace, no duplication.

Test plan

  • bun run build — clean, output styles.css shows the alias chain (--dg-color-card: var(--color-card) on [data-dg-agent], --color-card: #222228 on the dark selector at the same element)
  • bun run test — 13 pass / 0 fail
  • bun run typecheck — clean

Unblocks

Once @deepgram/ui ships the next patch, follow-ups land in order:

  • @deepgram/agents-widget bumps @deepgram/ui dep, cuts a release
  • CDN /widgets/latest/widget.umd.js rolls forward
  • deepgram-docs#777 demo styling renders correctly in dark mode (mic/speaker buttons, textarea, themed Aurora demo)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

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

Project Deployment Actions Updated (UTC)
ui-web Ready Ready Preview, Comment May 11, 2026 3:03pm

Request Review

@lukeocodes lukeocodes merged commit f94cec8 into main May 11, 2026
4 checks passed
lukeocodes added a commit to deepgram/agent that referenced this pull request May 11, 2026
#57)

## Summary

Picks up [deepgram/ui#37](deepgram/ui#37) so the
widget UMD ships with Tailwind v4 utility classes that actually follow
`[data-dg-scheme="dark"]` overrides.

## Why this needs a manual PR

The renovate.json on this repo sets `minimumReleaseAge: "11 days"`, so
renovate would sit on `@deepgram/ui@0.1.4` until ~May 22 before
proposing the bump. The 11-day soak is correct for third-party deps but
the wrong shape for shipping our own fix end-to-end through the agent
stack.

## The bug it unblocks downstream

`@deepgram/ui` ships Tailwind v4 with `prefix(dg)`, so utility classes
like `.dg:bg-card` read `var(--dg-color-card)`. The `@theme` block
declares the public token as `--color-card` (Tailwind auto-pairs it to
`--dg-color-card` at root), but every dark-mode override block only
touched the unprefixed namespace — so in dark mode the utilities kept
resolving to the light-mode `#f3f4f6` (visible as near-white mic/speaker
toggles and a blown-out textarea border inside the widget). 0.1.4
aliases every `--dg-color-*` to `var(--color-*)` on `[data-dg-agent]`,
so dark-mode and external theme overrides on the public `--color-*` API
propagate through to the utilities.

Inside this PR, the rebuilt `dist/widget.umd.js` now contains both
`--dg-color-card: #f3f4f6` (the light-mode default Tailwind emits from
`@theme`) **and** `--dg-color-card: var(--color-card)` scoped to
`[data-dg-agent]`, so consumers in dark mode get the dark card colour
through the alias.

## Test plan

- [x] `bun install` — lockfile updated, no peer warnings
- [x] `bun run --filter '@deepgram/agents-widget' build` — clean, UMD
390.83 KB (was 389.86 KB on CDN — alias block adds ~1 KB)
- [x] `bun run --filter '@deepgram/agents-widget' test` — 29 pass / 0
fail
- [x] Verified rebuilt UMD contains `--dg-color-card: var(--color-card)`
alias and dark-mode override on `[data-dg-agent][data-dg-scheme="dark"]`
still sets `--color-card: #222228` (so utilities resolve through the
alias to the dark value)

## Unblocks

- release-please picks this up → `@deepgram/agents-widget@0.1.7`
- CDN deploy workflow rolls `/widgets/latest/widget.umd.js`
-
[deepgram-docs#777](deepgram/deepgram-docs#777)
demos render correctly in dark mode (mic/speaker toggles, textarea,
Aurora demo's custom token overrides)
- Asana follow-up: [Ship @deepgram/agents-widget 0.1.7 with dark-mode
CSS
fix](https://app.asana.com/1/411927538413705/project/1210403316564421/task/1214722320021307)
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