Hiding Background Image After Logging In

Hello guys,

Just wanted to ask if it is possible to Hide the Background image after logging in.

Currently, I have this code that sets the background image of the Application. However, the problem is how can I disappear/hide the image after logging in back to plain white again.

CSS:
st.markdown(
β€œβ€"

.stApp {
background-image: url(β€œ#”);
background-attachment: fixed;
background-size: cover;
}

β€œβ€",
unsafe_allow_html=True
)

Thank you in advance.

You can just make the css only load if the person is not logged in, like this

import streamlit as st


def is_logged_in():
    return st.checkbox("Log in")


if not is_logged_in():
    st.markdown(
        """
    <style>
        .stApp {
            background-image: url("http://placekitten.com/400/200");
            background-attachment: fixed;
            background-size: cover;
        }
    </style>
    """,
        unsafe_allow_html=True,
    )

else:
    pass
1 Like

Thanks @blackary. Will try this on my end.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.