St.dataframe header and index font color

Hi community,

How do I change the font size or color of the columns header in st.dataframe ?
Right now the color is too bright. Any workaround?

example:

Blockquote
import pandas as pd
import streamlit as st

data = {
“calories”: [420, 380, 390],
“duration”: [50, 40, 45]
}

df = pd.DataFrame(data)
st.dataframe(df)

image

Thanks in advance.

1 Like

@ori

a bit of css for these divs works just fine:

div[class="ReactVirtualized__Grid table-bottom-left"] div,
div[class="ReactVirtualized__Grid table-top-right"] div {
    color: red;
}

Thanks Igor,
but how do you actually implement that in code?
Why doesn’t the Streamlit API offer a solution for this because the color is rather annoying?
Thanks :))

@ori
I do something like this:

  • create file called style.css in my project folder
  • put mentioned css code in it
  • and last thing, in my python file straight after calling st.set_page_config() add following code in order to apply css to my app :
import os

curdir = os.path.dirname(os.path.realpath(__file__)) + r'\\'
css_file = os.path.join(curdir, 'style.css')

def local_css(css_file):
    with open(css_file) as f:
        st.markdown('<style>{}</style>'.format(f.read()), unsafe_allow_html=True)

local_css(css_file)

Why doesn’t the Streamlit API offer a solution for this because the color is rather annoying?

I believe they have been focused more on performance staff lately)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.