How to execute function on hyperlink text

Hello Everyone!!

I am working to create a login sign up page using streamlit. I am facing an issue regarding working of hyperlink text.

Basically, I want when I click on SignUp hyperlink text, my SignUp function will work and when I click on reset it hyperlink text, it should execute the password reset functionality (The functions for SignUp and Reset Password is declared in the same file)

Please see the attached picture: (I have highlighted the hyperlink text)

Below is the relevent part that is not working

    st.markdown('<div class="footer">', unsafe_allow_html=True)
    sign_up_link = st.empty()
    reset_link = st.empty()
    sign_up_link.markdown('Don\'t have an account? <a href="#" onclick="window.stPydeckHandler.openUrl(\'/sign_up\');">Sign Up</a>', unsafe_allow_html=True)
    reset_link.markdown('Forgot your password? <a href="#" onclick="window.stPydeckHandler.openUrl(\'/forgot_password\');">Reset it</a>', unsafe_allow_html=True)
    st.markdown('</div>', unsafe_allow_html=True)

You would need to build a custom component to do that. Instead, try looking at tertiary buttons. Streamlit 1.41.0 just introduced “tertiary” style buttons which have no border, so they appear like plain text.

import streamlit as st

cols = st.columns([1,1,6])
cols[0].button("Log in", type="primary")
cols[1].button("Sign up", type="secondary")
st.button("Forgot your password?", type="tertiary")
1 Like