Display a feedback widget.
A feedback widget is an icon-based button group available in three styles, as described in options. It is commonly used in chat and AI apps to allow users to rate responses.
Function signature[source] | |
---|---|
st.feedback(options="thumbs", *, key=None, disabled=False, on_change=None, args=None, kwargs=None) | |
Parameters | |
options ("thumbs", "faces", or "stars") | The feedback options displayed to the user. options can be one of the following:
|
key (str or int) | An optional string or integer to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. |
disabled (bool) | An optional boolean that disables the feedback widget if set to True. The default is False. |
on_change (callable) | An optional callback invoked when this feedback widget's value changes. |
args (tuple) | An optional tuple of args to pass to the callback. |
kwargs (dict) | An optional dict of kwargs to pass to the callback. |
Returns | |
(int or None) | An integer indicating the user's selection, where 0 is the lowest feedback. Higher values indicate more positive feedback. If no option was selected, the widget returns None.
|
Examples
Display a feedback widget with stars, and show the selected sentiment:
Display a feedback widget with thumbs, and show the selected sentiment:
Still have questions?
Our forums are full of helpful information and Streamlit experts.