Skip to content

fix(#4009): align checkbox and radio item label weight and color#4010

Open
twjeffery wants to merge 1 commit into
devfrom
claude/confident-bell-2WDNZ
Open

fix(#4009): align checkbox and radio item label weight and color#4010
twjeffery wants to merge 1 commit into
devfrom
claude/confident-bell-2WDNZ

Conversation

@twjeffery

Copy link
Copy Markdown
Collaborator

Before (the change)

The checkbox label and the radio item label rendered differently even though they are the same kind of form control label, side by side:

  • Checkbox label: correct color (--goa-checkbox-color-label) but regular weight (400). The font shorthand from --goa-checkbox-label-font-size resolves to the regular body token, so the label was regular.
  • Radio item label: correct medium weight (500) but no color set, so it inherited the host default (near black) instead of the secondary input text color the checkbox uses.

So each was wrong on a different axis.

After (the change)

Both labels now render in medium weight (500) and resolve their color the same way, through their own component token pointing at the shared secondary input text color.

  • Checkbox (Checkbox.svelte, .text and .v2.compact .text): added font-weight: var(--goa-font-weight-medium). The font shorthand resets weight to the token default, so it has to be restated, including on the compact label whose shorthand also resets it.
  • Radio item (RadioItem.svelte, .label): added color: var(--goa-radio-color-label, var(--goa-input-color-text-secondary)). This introduces a new --goa-radio-color-label component token (to be defined the same way as --goa-checkbox-color-label in the tokens package) and falls back to the shared --goa-input-color-text-secondary so the color resolves correctly today, matching the repo's V2 fallback convention. No color change was needed on the checkbox; it already resolves correctly.

This is a CSS only change in the Svelte source, so the React and Angular wrappers did not need updates (wrappers pass attributes through and own no styling).

Make sure that you've checked the boxes below before you submit the PR

  • I have read and followed the setup steps
  • I have created necessary unit tests
  • I have tested the functionality in both React and Angular.

Steps needed to test

  1. Run the React playground: npm run serve:prs:react and open the 4009 Checkbox and radio label consistency page from the side menu.
  2. In Test 1, confirm the checkbox label and the radio item label match: both medium weight and both the secondary input text color (#353535 in light theme).
  3. In Test 2, confirm the compact checkbox label keeps its smaller font size but is still medium weight.
  4. In Test 3, confirm disabled labels still use their disabled color and are unaffected.
  5. Repeat in the Angular playground: npm run serve:prs:angular, same 4009 page.

Tests

  • Extended checkbox.browser.spec.tsx: asserts the base and compact labels consume the medium font-weight token.
  • Extended radio.browser.spec.tsx: asserts the item label resolves its color through the shared secondary input text token via the new component token's fallback.
  • Verified both new tests fail without the source change and pass with it (Chromium and Firefox).

Fixes #4009


Generated by Claude Code

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://GovAlta.github.io/ui-components/pr-preview-angular/pr-4010/

Built to branch gh-pages at 2026-06-08 18:47 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown

Preview links

Target URL
Docs https://govalta.github.io/ui-components/pr-preview/pr-4010/
React playground https://govalta.github.io/ui-components/pr-preview-react/pr-4010/
Angular playground https://govalta.github.io/ui-components/pr-preview-angular/pr-4010/

Built from commit 3d620c7. Previews are removed automatically when this PR closes.

@twjeffery twjeffery marked this pull request as ready for review June 3, 2026 23:27
@twjeffery twjeffery requested a review from bdfranck June 4, 2026 22:04
});
});

it("applies the medium font-weight token to the label", async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we sure we want to add these browser tests? We normally use these tests for regressions in functionality, not styling. I don't know how I'd feel if someone's PR was blocked because of a font weight.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good call. I've removed the browser style assertions from both checkbox.browser.spec.tsx and radio.browser.spec.tsx so this fix won't gate PRs on a computed font weight or color. The change is verified visually via the 4009 playground pages in React and Angular instead. (The web-component unit tests for both components still pass.)


Generated by Claude Code

@bdfranck bdfranck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I reviewed the changes...

  • ✅ I see the checkbox label is the correct font weight
Image
  • ✅ I see the radio item label is the correct colour
Image

Looks good to me! 👍 I have one comment about the tests.

Checkbox and radio item labels rendered inconsistently. The checkbox
label had the correct color but regular weight, while the radio item
label had the correct medium weight but no color, so it inherited the
near black page default instead of the secondary input text color.

Set font-weight: medium on the checkbox base and compact labels (the
font shorthand resets the weight to the token default), and resolve the
radio item label color through a new --goa-radio-color-label component
token that falls back to the shared --goa-input-color-text-secondary,
matching how the checkbox label resolves its color.

Adds React and Angular playground pages.
@twjeffery twjeffery force-pushed the claude/confident-bell-2WDNZ branch from 42f8c24 to 3d620c7 Compare June 8, 2026 18:44
@twjeffery twjeffery requested a review from bdfranck June 8, 2026 22:13

@bdfranck bdfranck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I looked at the latest changes and see the browser tests are gone. Looks good to me! 👍

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.

Checkbox and radio item labels have inconsistent weight and color

3 participants