When I click a button on the sidebar, the color changes from black to red. How do I reset the colors? My expectation is the color would change on hover and restore on button up. Instead it remains red.
import streamlit as st
if st.sidebar.button("Do it"): # turns from black to red then stays red.
When I run that exact code as you’ve put it, it behaves like this for me: it changes to light red on hover, goes darker red on click, and then changes back to light red. If you click anywhere else on the page, it then turns to black. It doesn’t stay red.
I actually didn’t notice that it turns back to black if I click elsewhere. My expectation is that the button will restore black on button up either automatically or at least a programmatic way to do so.
Perhaps this is actually a focus issue specific to streamlit. The button has focus after a click. The solution is to change focus to an input box in the main area, I don’t believe streamlit has a built-in way to change focus without resorting to css. So I might need to hack the button if I want my desired behavior.
I’ve implemented the ability to button press and change focus plus other features. ChatGPT Style Example SOTA
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.