Button css for streamlit

st.markdown(
    """
    <style>
    .element-container:has(style){
        display: none;
    }
    #button-after {
        display: none;
    }
    .element-container:has(#button-after) {
        display: none;
    }
    .element-container:has(#button-after) + div button {
        background-color: orange;
        }
    </style>
    """,
    unsafe_allow_html=True,
)
st.button("button1")
st.markdown('<span id="button-after"></span>', unsafe_allow_html=True)
st.button("My Button")
st.button("button2")

Added optimization of spacing based on @Ali_Attieh’s answer.

1 Like