Fit auto width columns

Summary

I created a Table using st.markdown on a Dataframe (with some additional styling). However it does not autofit the column width, leaving some columns to be too wide (wasting space) while congesting others columns/fields (causing it to be multiple lines).

Steps to reproduce

Code snippet:

opp_hihglight = load_io_df()

headers1 = {
    "selector": "th:not(.index_name)",
    "props": "background-color: #3B4759; color: #F2F2F2; text-align: left; border-color: #F2F2F2; border-left: 1px solid #F2F2F2 !important; width: 100%"
}
properties = {"border": "1px solid grey", "width": "100%", "text-align": "left"}

st.markdown(opp_hihglight.style.hide(axis="index").set_table_styles([headers1]).set_properties(**properties).to_html(), unsafe_allow_html=True)

I tried using "width": "100vw" in the properties as per this post (python - Set width to 100% (fill container) with pandas set_table_styles - Stack Overflow) but to no avail.

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