What is the best way to make cell contents clickable as hyperlinks today?
Various approaches have been put forward over the years but the ag-grid approach seems to have stopped working. cf. How to display a clickable link pandas dataframe - #5 by edsaac – just displays an empty frame. The to_html approach is, frankly, clunky and not very streamlitian (what’s the word for that?)
It looks like the new underlying tech for st.dataframe – glide-data – supports clickable hyperlinks via an @urlcolumn parameter https://github.com/streamlit/streamlit/pull/5972 – but did that make it into 1.19? Is it coming soon in 1.20?
Ideas for best practice going forward? @lukasmasuch ?
Updating here to share the latest update to LinkColumn in dataframes as of Release 1.30.0. You can now display custom text for your links instead of just seeing the raw URL!
Looking forward to hearing what you think and seeing your new dataframes!
# NOTE: st.dataframe does does not currently have a straightforward solution yes to display hyperlinks in st.dataframe().
# display_text can only be a part of the URL not something else. For example if the link is ‘www.toyota.com’ and you want display_text to be ‘camry’ you can’t do that. You can only display ‘toyota’ using a regex
# To solve this we add the display_text at the end of the url using ‘#’. The browser ignores anything after # in the url. example: www.toyota.com#camry
# Then we use this regex: r"https://.*?#(.*)$" to extact the display_text from the url.
# So this should display camry with a link to wwww.toyota.com