My main motivation was to be able to use FontAweseome Icons in Button Labels. Furthermore, it was important to me that I can align the buttons easily left, right, center.
Primarily, I use these buttons as download buttons. In this mode, they do not return a value and the page does not refresh. The return of a value can be controlled by the return_value parameter.
Some examples:
Button with FontAwesome Icon:
ButtonGroup with 3 Buttons:
Custom CSS Styling:
Example 1:
Example 2:
One thing to note:
The buttons offer three distinct modes, which can be configured through the mode parameter.
Default: Acts like a normal button, but unlike Streamlit Buttons, these buttons maintain their value after script re-execution.
Radio: Functions as a radio button, where only one button remains active at any given time.
Checkbox: Works like a checkbox, enabling the toggling of multiple buttons concurrently.
Hey @Tian,
I have started using your component and I want to ask you if it is possible to return the ‘value’ from the buttons dictionary instead of the index/position of the button that is being clicked on.
I am having trouble downloading the updated version.
ERROR: st-btn-group has an invalid wheel, st-btn-group has an invalid wheel, multiple .dist-info directories found: st_btn_group-0.0.10.dist-info, st_btn_group-0.0.9.dist-info
Is this something on my end or maybe an issue when uploading to pypi?
@Tian Hey, thanks a lot for this contribution!
I am using this in a chat bot (st.chat_input, st.chat_message) to show a like/dislike option after each response. The issue is, as soon as it reaches the code block for st_btn_group, the app reruns multiple times, that makes it very glitchy. Is there any possible solution for this?
Hey @Tian, thankyou for the solution. I have the case where I need to have st.rerun() once the button is clicked, but in your case the program runs in endless loop. Would it be possible to modify in a way that it behaves as st.button() so that it won’t go in a loop.
The following block creates a problem,
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.