Home > database >  How to create a button with Hyperlink in Streamlit?
How to create a button with Hyperlink in Streamlit?

Time:10-10

I would like to create a button with a Hyperlink in Streamlit. I thought maybe using st.button with this syntax: [Click Here](https://stackoverflow.com). But unfortunately this has no success, it only displays the text and doesn't make it as a hyperlink. I found enter image description here

As you can see, it doesn't create a hyperlink. So I was wondering if anyone knows how to create a button with a hyperlink in Streamlit?

CodePudding user response:

You can use markdown, a and button tags.

import streamlit as st

url = 'https://stackoverflow.com'

st.markdown(f'''
<a href={url}><button style="background-color:GreenYellow;">Stackoverflow</button></a>
''',
unsafe_allow_html=True)

enter image description here

  • Related