Summary
I am unaware of how to access HTML Elements within a Streamlit Page.
Steps to reproduce
Code snippet:
st.button("Log me in", key="Login_Button", on_click=self.login)
Let’s say I want to delete this button. Is there a Streamlit way to get this done?
Any help is appreciated.
Thanks in advance, Günther
Using callbacks and session states should be able to achieve that behavior. Here is an example.
import streamlit as st
if "is_logged_in" not in st.session_state:
st.session_state["is_logged_in"] = False
def login():
if "btn_login" in st.session_state:
st.session_state["is_logged_in"] = True
if not st.session_state["is_logged_in"]:
st.button("Login", key="btn_login", on_click=login)
else:
st.write("Logged in!")
Hello Carlos,
thank you so much for your answer. You are absolutely correct, that this solves the problem. The question went more in the direction on how Streamlit supports manipulating DOM Elements.
Thanks for your time and have a great day.
br, Günther