Skip to content

fix(react-ui): Button icons follow the button's text color - #57

Merged
sistrall merged 2 commits into
masterfrom
fix/react-ui-button-icon-color
Sep 30, 2026
Merged

sistrall merged 2 commits into
masterfrom
fix/react-ui-button-icon-color

Conversation

@roger-datocms

@roger-datocms roger-datocms commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Problem

In Web Previews' config screen, the trash icon on the red Remove frontend button is purple (Basecamp card). The bug is in datocms-react-ui, not in the plugin.

Button/styles.module.css hardcoded --color--ink-link on every button icon. The rule dates from 2021 (--accent-color, later renamed twice). As a result:

  • negative: accent icon on a red surface.
  • primary: accent icon on an accent surface, near-invisible in light mode.
  • Disabled: icon keeps the link color (accent in light mode, near-white in dark) while the label goes grey.

Fix

Icons now use currentColor, so each variant's own ink applies. This matches the CMS's button CSS (styles/blocks/_button.css), which fills icons with primary-soft--ink (muted), primary--ink (primary), danger--ink (negative) and disabled--ink (disabled). ButtonLink shares these classes and gets the same fix.

Visible changes to expect:

  • Muted buttons in light mode don't change: ink-link and primary-soft--ink both resolve to pigment-550, in every theme.
  • Disabled buttons in dark mode get a dim grey icon instead of a near-white one, matching the label and the CMS's own disabled buttons.

Includes a patch changeset for datocms-react-ui.

Before/After Screenshot

(Left = before, right = after)

all-themes

Testing

A Playwright harness renders the built Button inside Canvas, for every live appearance option:

  • Monochromatic palettes: 13 hues (every 30°, plus 7, the Jan 2024 default; 270 is the current default).
  • Grandfathered custom palettes: the pre-2024 default, a near-gray primary, and a light yellow accent.
  • Both color schemes for each.

Each theme's tokens come from the CMS's own pipeline: its pigment and wash ramp builders, its semantic-token CSS, read back the way readCSSDesignTokens builds ctx.cssDesignTokens. The harness checks each icon's computed fill against both the label color and the CMS's expected token, across 3 types × enabled/disabled.

  • Before: 176/192 fail. Only light-mode muted buttons pass, because both tokens resolve to the same palette stop.
  • After: 192/192 pass.

npm run build and npm test pass.

🤖 Generated with Claude Code

The icon rule hardcoded `--color--ink-link` for every button type, so
icons stayed accent-colored on red negative buttons, on primary buttons
(near-invisible in light mode), and on disabled buttons. `currentColor`
picks up each variant's own ink, matching the CMS's button CSS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@roger-datocms
roger-datocms marked this pull request as draft September 29, 2026 14:59
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/datocms-react-ui@94c6359
npm i https://pkg.pr.new/datocms-plugin-sdk@94c6359

commit: 94c6359

@roger-datocms
roger-datocms marked this pull request as ready for review September 29, 2026 16:39
@roger-datocms roger-datocms self-assigned this Sep 29, 2026
@roger-datocms roger-datocms added the bug Something isn't working label Sep 29, 2026
@sistrall sistrall self-assigned this Sep 30, 2026
@sistrall
sistrall merged commit ae7a57b into master Sep 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants