Repository navigation
Description
Summary
packages/ui/src/components/ui/alert.tsx has three variants: default, warning, and
destructive. destructive uses the themed --destructive token (a real CSS custom property,
contrast-checked — modulo draft 03's missing -foreground). warning instead hardcodes a raw
Tailwind palette class, text-amber-600 (line 13), because there is no --warning token in
default.css to use. Measured against --card (the surface Alert renders on,
alert.tsx:12: bg-card), amber-600 reads 3.19:1 as body text — under the 4.5:1 WCAG 1.4.3
floor for normal text.
This isn't limited to the one component. Because upstream's theme has no --success/--warning
tokens at all, every call site in the app that needs to communicate success or a non-destructive
warning as text reaches for the same family of raw, hardcoded classes. The two most common,
counted directly (apps/**/*.tsx, packages/**/*.tsx):
$ git grep -n -E "text-amber-600|text-emerald-600" upstream/main -- 'apps/*.tsx' 'packages/*.tsx' | wc -l
15
text-emerald-600 (the success equivalent) reads 3.77:1 on --card — also under 4.5:1.
Control: the destructive variant in the same component, on the same surface, at the same font
size, passes (--destructive is a real theme token with a contrast-checked value against
--card) — so this isn't Alert failing generally, it's specifically the two variants that
don't have a themed color to draw from.
Environment
| Defect type | Static (code) |
| Commit | 975c7a02a963d80bf140bb269d773b4912b8e7b6 (upstream/main) |
| How measured | git fetch upstream && git rev-parse upstream/main, then reading packages/ui/src/components/ui/alert.tsx and packages/ui/src/styles/default.css at that commit, and running the WCAG 2.x contrast math against the literal hex/oklch values those Tailwind classes resolve to |
How to see it
packages/ui/src/components/ui/alert.tsx, lines 12-13:warning: "text-amber-600 dark:text-amber-500 bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-amber-600/90 dark:*:data-[slot=alert-description]:text-amber-500/90",- Compute the WCAG 2.x contrast of Tailwind's
amber-600(oklch(0.666 0.179 58.318)) and
emerald-600(oklch(0.596 0.145 163.225)) against--cardin light mode
(oklch(1 0 0)— plain white).
Evidence
$ pnpm exec tsx medir-amber700-detalle.ts
amber-600/emerald-600 (actual) [
'estado-texto-success=3.77',
'estado-texto-warning=3.19',
'estado-icono-warning=2.80'
]
(estado-icono-warning is the same amber-600 value used as an icon color, e.g. a
TriangleAlertIcon, checked against the 3:1 non-text floor. Correction (2026-09-25): that 2.80
was measured with the icon on a 12% amber tint over the card, not on the plain bg-card that Alert
renders. On bg-card the icon is 3.19:1 and passes; see the comments below.)
Usage count for the two hand-written text classes:
$ git grep -n -E "text-amber-600|text-emerald-600" upstream/main -- 'apps/*.tsx' 'packages/*.tsx' | wc -l
15
(Witness: git grep -l -E "text-amber-600|text-emerald-600" upstream/main -- 'apps/*.tsx' 'packages/*.tsx' lists real files, e.g.
apps/builder/src/features/ads/components/ads-analytics-view.tsx.)
Control (the destructive variant of the same component passes):
--destructive (oklch(0.577 0.245 27.325) light) against --card is not in the failing-rows
list produced by the same script run against unmodified default.css — only the success/warning
text and icon criteria are.
Where it comes from
packages/ui/src/components/ui/alert.tsx lines 12-13 (the warning variant); the equivalent
hardcoded text-emerald-600 usages are scattered across the 15 call sites counted above, none of
which import a --success/--warning custom property because default.css doesn't define one.
Why we think this is a defect rather than the intended design
This is a proposal grounded in a measured contrast defect, not a feature request for new
capability the app doesn't already need — the app already communicates success and warning
states as colored text in at least 15 places; those two colors both fail the same WCAG 1.4.3
floor the destructive variant already meets. We are not asking upstream to invent a new visual
language, only to make the two states it already has as contrast-safe as the third one
(destructive) it already ships correctly.
Suggested fix
Add --success/--warning tokens (with their -foreground counterparts, mirroring how
--destructive/--destructive-foreground — modulo draft 03 — are structured) to :root/.dark
and register them in @theme inline, then point alert.tsx's warning variant (and, over time,
the other 14 call sites) at the token instead of the raw class:
/* :root */
--success: oklch(0.527 0.154 150.069); /* Tailwind green-700 */
--warning: oklch(0.555 0.163 48.998); /* Tailwind amber-700 */Verified with the same script, substituting these values for the current hand-written
amber-600/emerald-600 pair:
$ pnpm exec tsx medir-amber700-detalle.ts
amber-700/green-700 (candidato) [
'estado-texto-success=5.00',
'estado-texto-warning=5.04',
'estado-icono-warning=4.27'
]
All three clear their respective floors (4.5:1 for text, 3:1 for the icon) with margin. We are
not sending a PR for this one: introducing new theme tokens and threading them through the
Alert variant map (and, ideally, the other 14 call sites) is a bigger, more opinionated change
than a two-line value swap, and it's the kind of API surface addition a maintainer should weigh
in on before code is written for it.
What we did not verify
- Dark-mode values for
--success/--warningbeyond the existing hand-written
emerald-400/amber-400pair, which already pass in dark mode today (not in the failing-rows
list) — we did not re-derive dark-mode-specific replacements since the light-mode ones are the
ones that fail. - The other 13 call sites beyond
alert.tsxand the two files sampled in Evidence — we counted
them, we did not open and re-verify contrast for each individually. - APCA / WCAG 3 numbers — only WCAG 2.x is measured here.
Related issues — none of these describes it
Searched gh search issues --repo ChatbotXIO/ChatbotX "<term>" for alert warning contrast and
warning text contrast (no --state filter); both returned zero results. Witness that the
mechanism works: the same command with "bug" returns real issues (e.g. #1226, #1228).
Activity
baokimho commentedon Sep 23, 2026
I checked this on current
main.The text contrast issue is reproducible:
amber-600: ~3.19:1amber-600/90: ~2.85:1emerald-600: ~3.77:1So the warning/success text does fail the 4.5:1 requirement.
One small difference: I couldn’t reproduce the reported 2.80:1 for the warning icon. The SVG inherits solid
amber-600, which is ~3.19:1 on the default card, so it narrowly passes the 3:1 non-text threshold.Before opening a PR, would you prefer a small palette fix, or adding
--success/--warningsemantic tokens and migrating the clear status usages?rawdaymx commentedon Sep 25, 2026
Thanks for checking this against current
main.You're right about the icon, and the issue overstated that row. Our 2.80:1 was measured with the icon on a 12% amber tint over the card, a surface from our own theme work, not on the plain
bg-cardthat theAlertwarning variant renders. Onbg-card, solidamber-600is 3.19:1 and passes the 3:1 non-text threshold, as you found. The text findings stand, and youramber-600/90figure (we get 2.85:1 too) means the description text fails by more than the title does, which the issue didn't point out.On your question, our preference is the semantic tokens. The root cause is that there is no themed colour to reach for, so a palette swap fixes today's call sites but the next one written will probably use
amber-600again. A scope that stays reviewable could be the tokens plus theAlertvariant in one PR, and the remaining call sites in a follow-up.That said, it's the maintainers' call, not ours. If they'd rather keep the change small, the palette fix is a fine first step and doesn't get in the way of adding tokens later. For reference,
amber-700andgreen-700both come out at about 5:1 on--card.rawdaymx commentedon Oct 2, 2026
Two more sites of this same root cause have appeared since this was filed. Reporting them here rather than opening a new issue, because the cause and the decision are the ones already on the table — and the second one bears directly on the
--success/--warningtoken question.Measured against
upstream/main=e4913ef2a.1.
apps/builder/src/features/broadcasts/components/broadcast-plan-limit-dialog.tsx:72—DialogTitlewithclassName="text-amber-600 dark:text-amber-500".DialogContentrenders onbg-popover, which isoklch(1 0 0)in light mode, so this is the plainamber-600-text-on-white case @baokimho measured at 3.19:1 — under the 4.5:1 floor for body text. Same number, new surface; nothing new to measure.To be explicit about what we are not claiming this time: the icon on line 68 sits on
bg-amber-500/10, which is the tint-over-surface shape that produced our original 2.80:1 and that you correctly pushed back on. We are not calling it a violation — it isaria-hiddenand decorative, with the title text next to it carrying the meaning, so 1.4.11 exempts it. Only line 72 is a text-contrast claim.2.
apps/builder/src/features/conversations/components/thread-control-tone.ts:19-23(consumed bythread-control-pill.tsx) — a new file that hard-codes the warning semantic:We are not claiming a contrast failure here, and we did not measure one:
amber-800onamber-50is a self-consistent dark-on-light pair, and the dark-mode variant is paired too. The reason it is worth mentioning is the shape of the file rather than its contrast. Its other two tones are fully tokenised —ownedusesborder-primary/30 bg-primary/10 text-primary,idleusesborder-border bg-muted text-muted-foreground. Onlystandbydrops to raw palette classes, and the only thing distinguishing it is that there is no token for "warning" to reach for.So this is the argument of this issue reproduced inside one new file, written after the issue was opened: a developer tokenising three tones correctly tokenises two and hand-writes the third. It also means a
--warningtoken would already have at least two consumers (this file and theAlertvariant), which is the thing that was uncertain when you asked whether to fix the palette or add tokens.Our preference is unchanged and still yours to decide: tokens. Happy to send the patch for either shape once you have picked one — including threading a new token through the existing call sites, if that is the direction.
What we did not verify
amber-600ourselves for site 1; we are citing @baokimho's 3.19:1, since it was measured on the same surface (bg-popoverandbg-cardare bothoklch(1 0 0)in light mode).standbypair in site 2 at all, in either mode — hence no claim about it.amber-*/emerald-*sites beyond these two; they came up while reading other code, not from a systematic search, so there may be more.fix(builder): improve status text contrast (#1619)
fix(builder): improve status text contrast (#1619)