I would like to know is there any updates for streamlit where we could use hyperlink without markdown? I need it for one of my application where the user would login and on clicking the link the app opens. Is this possible?
Hey @harish_natarajan,
Can you clarify what you mean? Maybe a little example code of what you have and what your trying to achieve?
Happy Streamlit-ing!
Marisa
Hey @Marisa_Smith. What I mean is something like streamlit.hyperlink( “link_name”). It would be nice to have such features in streamlit of its not there already. Expecting to see this feature soon.
Regards
Harish
Hey @harish_natarajan,
I believe that we already have the feature your looking for, you can definitely put hyperlinks in a Streamlit app
import streamlit as st
st.write("check out this [link](https://share.streamlit.io/mesmith027/streamlit_webapps/main/MC_pi/streamlit_app.py)")
will produce:
check out this link
Cheers!
Marisa
Hey @Marisa_Smith,
Thanks for the reply. I wasn’t knowing this exist. It would be extremely useful for my future project. Thank you.
Regards
Harish
@Marisa_Smith, it’s similar to adding links in GitHub markdown right?
yes it is!
Hi @Marisa_Smith I would like to create an icon that links to a page.
Is it possible? Thanks in advance.
Hey @ParthRangarajan,
First, Welcome to the Streamlit community!
Not that I know of or have tried, but that doesn’t mean that the community hasn’t found an answer (or have an idea) of how you might be able to do that.
I would peruse the wealth of knowledge here on the forum and if you can’t find what your looking for make a new post and see what others have to say! (the new post will be easier for others to find and answer than continuing a thread here!)
Happy Streamlit-ing!
Marisa
Hi Marisa!
Thank you for the solution.
I’d like to know what st.write(’…x’) means. What’s the purpose of and ()?
Also, the link that you pass in (), what type is it.
Because I tried doing this :
st.write(“check out this link”)
where,
source_url is a string variable.
It does produce :
check out this [link]
But when I click on the “link”, it gives me this : 404 not found error
http://1**...:8*/source_url
@Soumya_Pandey
Have you gotten solution to this??? if not, i have a crack
while i understand whta you are trying to achieve, you can follow this step;
import streamlit as st
link='check out this [link](https://retailscope.africa/)'
st.markdown(link,unsafe_allow_html=True)
Let me know if this works for you and mark as answer
Hello Kareem,
thank you for the reply.
Again, the solution you’ve provided is hardcoded. Instead of writing the link, I want to give in a string variable that would keep on changing values.
When I apply your solution, the same thing happens, the following URL gets created :
http://1*...1**:8***/source_url*
Okay, have you gotten a solution now???
Rasheed Abdulkareem
(Bsc, MOS, MCP, NIMRA)
Hi @Soumya_Pandey,
Ah you are looking to make the link dynamic well you can use a format statement. This is actually a question on formatting python strings and you do exactly what we suggested above, but just adding a format statement to pass in a variable to the string parameter and not a hardcoded website link:
a_link = st.multiselect("choose a link", [url_a,url_b])
# mock up of a user who can dynamically change the link, url_a and _b
# need to be actual web addresses
text='check out this [link]({link})'.format(link=a_link)
st.markdown(link,unsafe_allow_html=True)
Happy Streamlit-ing!
Marisa
what if the link is stored in form of string in a variable…
Is there any way to apply that to the sidebar?