Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

st.dataframe() with highlight is hard to read in dark mode #6060

Closed
3 of 5 tasks
whitphx opened this issue Feb 3, 2023 · 3 comments · Fixed by #6098
Closed
3 of 5 tasks

st.dataframe() with highlight is hard to read in dark mode #6060

whitphx opened this issue Feb 3, 2023 · 3 comments · Fixed by #6098
Labels
feature:st.dataframe status:confirmed Bug has been confirmed by the Streamlit team type:enhancement Requests for feature enhancements or new features

Comments

@whitphx
Copy link
Contributor

whitphx commented Feb 3, 2023

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

The background color of the highlighted cells in st.dataframe() table is kept as yellow even in dark mode, while the text color changes to white.
As a result, in dark mode, the highlighted cells are very hard to read.
CleanShot 2023-02-03 at 23 19 03@2x

Reproducible Code Example

Open in Streamlit Cloud

import streamlit as st
import pandas as pd
import numpy as np

df = pd.DataFrame(
   np.random.randn(10, 20),
   columns=('col %d' % i for i in range(20)))

st.dataframe(df.style.highlight_max(axis=0))

Steps To Reproduce

No response

Expected Behavior

The background color should also be nicely selected by default in combination with the text color.

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.17.0
  • Python version: Python 3.10.6
  • Operating System: macOS 13.1
  • Browser: Sidekick (chrome-based) Version 108.35.1.29385 (Official Build) (arm64)
  • Virtual environment:

Additional Information

color='red' for example provide a visible color combination like st.dataframe(df.style.highlight_max(axis=0, color='red')).

CleanShot 2023-02-03 at 23 23 17@2x

Are you willing to submit a PR?

  • Yes, I am willing to submit a PR!
@whitphx whitphx added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Feb 3, 2023
@carolinedfrasca carolinedfrasca added type:enhancement Requests for feature enhancements or new features feature:st.dataframe and removed type:bug Something isn't working labels Feb 3, 2023
@carolinedfrasca
Copy link
Contributor

Thank you for sharing this, @whitphx!

@kajarenc kajarenc added priority:P2 status:confirmed Bug has been confirmed by the Streamlit team and removed status:needs-triage Has not been triaged by the Streamlit team labels Feb 7, 2023
@lukasmasuch
Copy link
Collaborator

@whitphx Thanks for reporting this issue. I was able to reproduce it here.

There is also an additional workaround by setting the font color manually:

st.dataframe(df.style.highlight_max(axis=0, props='color:black;background-color:yellow;'))

In general, Pandas Styler is not aware of the theming and we are currently not interfering with whatever styling information Pandas Styler provides. We could theoretically add some kind of smart font color selection based on the background (light font color for dark background, dark font color for light background), but this would need a bit more refactoring and evaluation on our side.

@lukasmasuch
Copy link
Collaborator

I added a small fix to have a dark text color activated as default if the background is yellow. This should fix the issue for all whenever highlight_max is used without specifying a different color.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:st.dataframe status:confirmed Bug has been confirmed by the Streamlit team type:enhancement Requests for feature enhancements or new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants