great_tables in Streamlit

Hi,

A similar topic was created last year, when a user wrote “Please give a thought to integrate great-tables with ST”

An answer from @edsaac suggested extracting an HTML representation of the GT table (using as_raw_html()) and passing that to st.html(). This seemed to have met the requirements of the user that created that topic.

I tried to do the same today, and noticed that a lot of the stuff that made me want to use great_tables in the first place, didn’t really make it to the html string. So e.g. flag representation of ISO2 codes (fmt_flag()), nanoplots (fmt_nanoplot()), basically “bells and whistles” stuff. Tried my luck with (inline_css=True) and (all_important=True), but it didn’t change things.

Can anyone think of other solutions to get a more “full” representation of a great_tables table into streamlit, that doesn’t require so a bunch of additional, custom code?

1 Like

To better integrate great_tables with Streamlit and retain features like flags and nanoplots:

  • Use st.write(html_content, unsafe_allow_html=True) instead of st.html() for better CSS/JS support.

  • Experiment with great_tables options inline_css=True and all_important=True.

  • Consider custom Streamlit components like AgGrid for richer interactive tables.

  • Post-process HTML to inject missing CSS/JS if needed.

  • Engage with great_tables community for improved Streamlit compatibility.

Exporting as raw HTML alone limits some complex interactive features.

Thank you for the suggestion. Using st.write did the trick!

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