Contrast issues in dark mode when rectangles with background colours are used
Author: SoviutCreated Aug 28, 2026Updated Sep 10, 2026
Labelsbug
Describe the bug
In dark mode, the font becomes difficult to read because it doesn't contrast with the light rectangle colours.
To Reproduce
Link to Live Editor:
Steps to reproduce the behavior:
- In the List Editor
- Create a
rect rgb(240, 248, 255) - Add any content
- Toggle dark mode on
- Observe that the lighter font is difficult to read on top of the rect background colour
Expected behavior
I should be able to read text within rectangles regardless of light or dark mode
Screenshots
Desktop (please complete the following information):
- OS: Windows 11
- Browser Chrome
- Version 151
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context
This could be solved using the newly baseline contrast-color() css function.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/contrast-color
Alternatively, the rect colours could be parsed and a suitable dark mode variant could be calculated.
Source: mermaid-js/mermaid-live-editor