I just tried your awesome component, and have a few observations and suggestions:
Observations:
I can put any number of stars via the parameter setting, but the same is not possible for emojis.
Suggestions:
allow the input of any icon (/small png/jpg…), so that customisation options increase.
rather than having different options for stars and emojis, just have an array of icon references, so that there is no restriction to the type of stars (or icon) and emojis only, and/or their number. I could then have… say… 7 options between thumbs up and thumbs down.
if the above is possible, then your component can also double up as an image selector. Further, if there is a parameter for orientation, your component can also be used in a narrow sidebar as an image selector.
I used this to make an poll app where user can just leave an “no idea” vote, but once they hit a star, then they can not return to “no idea” even when they rerun
Thank you for your effort, I really appreciate that. A reset button can solve problem but not simple. I will try another way to redesign the user experience in stead.
Great and in demand component! Thank you!
What is the best way to associate callback function with this widget? Tried with on_click attribute but no way. Need to create streamlit demo app with list of elements and possibility for user to leave feedback for each item. And would like to trigger storing feedback just after user clicked some star. I know, as a workaround, I could also add button for user like ‘send feedback’, but would like to have solution with single click for user.
I have added the paramter “on_click”. You can provide a python function to the parameter. Everytime the components gets clicked and a value is returned the function will be executed.
I can initialize the component with a star rating (1-5) as the defaultvalue from a postgresql record when loading the streamlit app and use the changed value of the star component to make an update to this record in the postgresql table.
However i wonder how to bind this star component to my sidebar selectboxes in the same way as with text_area components.
Currently after loading the page the star component gets populated with the star rating of the record currently selected, but if i then switch to another record id the star component will not be updated.
If I set the label to empty (“”), then the highlighted star is cut off at the bottom when the mouse is over it
Here is a screenshot taken from the example app (st-star-rating-component.streamlit.app):
The same effect happens on the left side.
I fixed this for me with this:
customCSS = “ul li:first-child { margin-left: 6px; margin-bottom: 15px}”
One solution might be to use the customCSS option. Since the label will result in an h3 tag, you can set its font-size directly:
customCSS = “h3 { font-size: 4px; }”
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.