Skip to content

fix(components): improve dark-mode error message contrast#2489

Open
amir-ba wants to merge 1 commit into
mainfrom
copilot/issue-2093-dark-mode-error-contrast
Open

fix(components): improve dark-mode error message contrast#2489
amir-ba wants to merge 1 commit into
mainfrom
copilot/issue-2093-dark-mode-error-contrast

Conversation

@amir-ba
Copy link
Copy Markdown
Collaborator

@amir-ba amir-ba commented Apr 27, 2026

Problem

In dark mode, error message text has insufficient contrast (WCAG 1.4.11). Introduces shared token --scl-color-form-error-message that switches to a higher-contrast color in dark mode.

Affected Components

helper-text, checkbox, radio-button, radio-button-group, combobox, input, text-field, textarea

Tests

E2E tests added for helper-text and checkbox dark-mode colors. All 404 component tests pass.

Closes #2093

Introduces a shared dark-mode token alias for danger/error text colors
across helper-text, checkbox, radio-button, combobox, input, text-field,
and textarea components, meeting WCAG 1.4.11 non-text contrast requirements.

Additionally fixes counter error colors in input, text-field, and textarea
to use the same token, ensuring consistent error text appearance in dark mode.

Closes #2093

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 27, 2026 17:32
@amir-ba amir-ba requested a review from maomaoZH as a code owner April 27, 2026 17:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves dark-mode accessibility by introducing a shared CSS custom property for form error message text color and migrating multiple components to use it, with added E2E coverage to prevent regressions.

Changes:

  • Adds global token --scl-color-form-error-message with light/dark (and prefers-color-scheme) mappings.
  • Updates affected component styles to consume --scl-color-form-error-message (with fallbacks) for error/helper text coloring.
  • Adds E2E assertions for dark-mode error/helper text colors in helper-text and checkbox.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/components/src/global/scale.css Introduces --scl-color-form-error-message and defines its light/dark + OS-preference behavior.
packages/components/src/components/textarea/textarea.css Switches meta error color token to the shared error-message variable.
packages/components/src/components/text-field/text-field.css Switches meta/helper error colors to the shared error-message variable and reformats some selectors.
packages/components/src/components/radio-button/radio-button.css Uses the shared error-message variable for helper-text error color.
packages/components/src/components/radio-button-group/radio-button-group.css Uses the shared error-message variable for error helper text color.
packages/components/src/components/input/input.css Uses the shared error-message variable for helper text/counter error color; minor formatting changes.
packages/components/src/components/helper-text/helper-text.css Uses the shared error-message variable for danger variant color.
packages/components/src/components/combobox/combobox.css Uses the shared error-message variable for danger color; minor formatting changes.
packages/components/src/components/helper-text/helper-text.e2e.ts Adds E2E assertion for dark-mode danger color.
packages/components/src/components/checkbox/checkbox.css Uses the shared error-message variable for helper-text and error icon color.
packages/components/src/components/checkbox/checkbox.e2e.ts Adds E2E assertion for dark-mode helper-text error color.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +28 to +33
const color = await page.$eval(
'scale-helper-text',
(element: HTMLElement) =>
getComputedStyle(
element.shadowRoot.querySelector('.helper-text') as HTMLElement
).color
Comment on lines +28 to +36
const color = await page.$eval(
'scale-helper-text',
(element: HTMLElement) =>
getComputedStyle(
element.shadowRoot.querySelector('.helper-text') as HTMLElement
).color
);

expect(color).toBe('rgb(251, 106, 85)');
Comment on lines +23 to +31
const page = await newE2EPage();
await page.setContent(
'<div data-mode="dark"><scale-checkbox label="Label" helper-text="This is the error message" invalid></scale-checkbox></div>'
);

const color = await page.$eval(
'scale-checkbox [part="helper-text"]',
(element: HTMLElement) => getComputedStyle(element).color
);
(element: HTMLElement) => getComputedStyle(element).color
);

expect(color).toBe('rgb(251, 106, 85)');
Comment on lines +73 to +76
--color-helper-text-error: var(
--scl-color-form-error-message,
var(--color-meta-error)
);
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.

While in dark mode the contrast of the error message is too low

2 participants