Skip to content

Keep tag colors readable on the dark theme - #1565

Merged
DavidMStraub merged 1 commit into
gramps-project:mainfrom
giang17:fix/tag-color-dark-theme
Oct 19, 2026
Merged

DavidMStraub merged 1 commit into
gramps-project:mainfrom
giang17:fix/tag-color-dark-theme

Conversation

@giang17

@giang17 giang17 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Linked issue

Closes #1310

What this changes

  • New tagColorToCss() in src/color.js: wraps the tag color in a relative color, oklch(from <color> clamp(var(--grampsjs-tag-lightness-min, 0), l, var(--grampsjs-tag-lightness-max, 1)) c h / alpha). Hue and chroma stay as they are, only the lightness is limited.
  • global.css sets --grampsjs-tag-lightness-min: 0.7 for the dark theme. The light theme defines no limits, so its tag colors are unchanged.
  • The tags manager, the tag chips on object pages and the tag chips in the media list use tagColorToCss() instead of colorToCss() for text, outline and background tint.
  • Browsers without relative color syntax (checked with CSS.supports) get the plain color as before.

With this, the default tag color black is shown as light grey on the dark theme; a red tag stays red with lightness 0.7 instead of 0.65.

How it was tested

  • test/unit/color.test.js: 4 new tests for tagColorToCss() (with and without relative color support, without CSS, invalid color). npm run lint and npm test (63 files, 1180 tests) pass.
  • Dev container with the example tree plus a temporary tag "Blog" with the Gramps default color #000000000000, Chromium 152, dark theme: in Administration → Tags the computed color of "Blog" is oklch(0.7 0 0 / 0.9) instead of black. On the light theme the computed colors of all three tags are unchanged (oklch(0 0 0 / 0.9) for "Blog"). The "ToDo" chip on person I0044 is clamped the same way on the dark theme.

Before / after on the dark theme:

Tags on the dark theme before the change: the black tag is barely visible

Tags on the dark theme after the change: the black tag is shown in light grey

Drafted with an AI assistant.


  • I have read CONTRIBUTING.md
  • This was discussed in an issue first, or it is small enough not to need one
  • I wrote this myself, or used an AI assistant and have reviewed every line

Tag chips use the tag color for text and outline. The default tag color
in Gramps is black, which is almost invisible on dark surfaces.

Add tagColorToCss(), which wraps the tag color in a relative oklch()
color that clamps its lightness to --grampsjs-tag-lightness-min/-max,
and set the minimum to 0.7 on the dark theme. Hue and chroma are kept,
the light theme is unchanged, and browsers without relative color
syntax get the plain color as before. Used by the tags manager, the tag
chips of object pages and the media list.

Fixes gramps-project#1310
@DavidMStraub

Copy link
Copy Markdown
Member

Thanks!

@DavidMStraub
DavidMStraub merged commit 4a0e8f7 into gramps-project:main Oct 19, 2026
1 check passed
@giang17
giang17 deleted the fix/tag-color-dark-theme branch October 20, 2026 10:18
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.

[Visual Bug] Administration Tags section on dark theme issue

2 participants