it seems i am unable to access the CSS variables for the default template colors.
Here is described that i can access them via background-color: var(–text-color);
Can you point out where i am wrong ?
import streamlit as st
@st.dialog("Edit")
def edit_table_data(x):
with st.popover("Edit"):
st.write(f"Editing {x}")
def display_table(table_data, column_formating = None, edit_function=False, has_header = True, header_color = None, alternating_row_colors = False):
modifier = 0 if not edit_function else 1
st.html("""<style> .st-key-rnd_table { display: block;} </style>""")
with st.container(key="rnd_table"):
for j,row in enumerate(table_data):
row_len = len(row) + modifier
if j == 0 and header_color:
style= f"{{background-color: {header_color};}}"
else:
if alternating_row_colors == True and ((j+1) % 2 != 0):
style = f"{{background-color: rgb(240, 242, 246);}}"
else:
style = f"{{background-color: transparent;}}"
with st.container(key=f"row_{j}"):
columns = st.columns(row_len if not column_formating else column_formating)
for i,col in enumerate(row):
columns[i].write(col)
if edit_function and (j != 0 and has_header):
with columns[i+1]:
if st.button("Edit",key=f'edit_{j}'):
edit_function(j)
st.html(f"""<style> .st-key-row_{j} {{ background-color: var(--text-color);}} </style>""") # should give a black/ white bar but just does nothing ?
# st.html(f"""<style> .st-key-row_{j} {{ background-color: green;}} </style>""") -- works nicely
data = [['First', 'Second', 'Third'],
['A', 'B', 'C'],
['D', 'E', 'F'],
['G', 'H', 'I']]
display_table(
data,
edit_function=edit_table_data,
header_color="var(--text-color)",
alternating_row_colors=True,
)