rich icon indicating copy to clipboard operation
rich copied to clipboard

[BUG] Text Color Not Adapting to Dark Mode in Windows 11 Terminal

Open kaidaniel82 opened this issue 2 years ago • 4 comments

Operating System: Windows 11 Pro Python Version: 3.11 Rich Library Version: 13.7

Problem Description: When I execute the following line in the terminal, the text remains black even when the terminal switches to Dark Mode, which has a black background. This makes the text unreadable.

Code where the issue occurs:

right_panel_content = Text( f"Internet: {app_status['internet']}\n", style="black")
Panel(right_panel_content, title=Text("Connectivity Center", style="bold"))

On the other hand, the following code will automatically adjust the text color to white when the display mode automatically switches to Dark Mode:

right_panel_content = f"License Name: {license_status['product_name']}\n"
Panel(right_panel_content, title=Text("License Center", style="bold"))

kaidaniel82 avatar Dec 09 '23 22:12 kaidaniel82

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

github-actions[bot] avatar Dec 09 '23 22:12 github-actions[bot]

Only the default foreground and background colors behave this way. The terminal will pick the appropriate shade, but some combinations are never going to work well. Like black on a dark background.

willmcgugan avatar Dec 10 '23 13:12 willmcgugan

Does that mean that no matter what color I set in the following code, it will never adjust?

Text(f"Internet: {app_status['internet']}\n", style="black")

kaidaniel82 avatar Dec 10 '23 14:12 kaidaniel82

Rich writes code that says make the foreground color black. It's your terminal that decides on the exact shade you get. You can configure your terminal to adjust theme colors. So you could change black to a dark grey or a different color entirely.

willmcgugan avatar Dec 10 '23 15:12 willmcgugan