Streamlit hyperlink

Hi all -

I want to create a hyperlink in streamlit and upon clicking, need to invoke a python function. I know, I can do it via., a button. Can the same achieved by Hyperlink ?

st.markdown(f"check out this link")

Hi @MrittiYogan,

Thanks for posting!

You can do the following:

url = ""
st.write("check out this [link](%s)" % url)
st.markdown("check out this [link](%s)" % url)

Caroline :balloon:


Thanks for the response. URL works. But I need to call a python function while someone clicks the link.

Hi @MrittiYogan,

What you’re looking for is the callback function via on_change or on_click that allows you to execute a Python function upload interaction with an input widget. As you have recalled, st.button supports callback and works in your case while st.write or st.markdown does not have a callback function and would not work. At the moment, st.button seems to allow what you’re looking for.

Hope this helps.

1 Like