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:

https://mermaid.live/edit#pako:eNp9VMFu2kAQ_ZXRnojiEGNsAlYVKSSH5tAmalMpqbgM9mBW8a7d9Tqpi_j3jo3tEEpqCRhmd95782ZgI6IsJhGKgn6VpCO6kZgYVAuz0MAPljbTpVqS6TORzQzcamklcvQ-_Y0imUvStkvnaKzkHGoLV_e3x9I382PZr5mVqwqw6KKB1GeY53AKpFCmJ8eK5hg9r2Sa1mV9PCiqwpI6OVSapxiRarV2h4YiCyZZDjzfdcDzp_wWBH0tayHIXmjPAGenL-TMi-TTyBBainu21MIX1CWmIJsL3UH99CBnl5fsTgj3d98f4FyhjdZUfFqa88uN6Sz9UZC5jR1IUFH9GTONA1Yq2u5jMg6j3cxD5uMKCy0a-2DRlkUIOelY6uSkwd-_dP9m5Y6cPW8FQm7oDKOIcu7NgV5UD_avhM4XvZtfO7e3FWkYFuIRXms-sBnwRCp4WohDLAbrnQrBc0dw_d5kSguCK15VVWd3zSh8Zl1QvBLlMNAyWdu04ulk-p3Wbk1az1ZSx7xS0hRQrNHUCLXfrD5FnZSYcNgIr5cg5X2sb-ALN4ZLmUpbOXW_PHUWGFet9_F_CA-GdPrRJJaZXe_venHU-T3wD-yf3z18hpI5ucFKKbJGRpimVTuNp6wEZAseAQ1BQ7oyRMPh8G0szHsQ1i_hiMTIWITWlOQIRYb5-KvY1FcXwq75x7YQIYcxmmeG01uu4V5-ZpnqykxWJmsRrpAn6ogyr5e8_Uvqs4ZZyVxnpbYiHM3cBkSEG_FbhJ4fDMfuxPUnF_5sNh5PfUdUIgzc4cydecHYCyaTUeD6wdYRfxpePhlNvPF0NJ1e-ONgNhpv_wKgUq0x

Steps to reproduce the behavior:

  1. In the List Editor
  2. Create a rect rgb(240, 248, 255)
  3. Add any content
  4. Toggle dark mode on
  5. 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

Image

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