Display a colored badge with an icon and label.
This is a thin wrapper around the color-badge Markdown directive. The following are equivalent:
- st.markdown(":blue-badge[Home]")
- st.badge("Home", color="blue")
Note
You can insert badges everywhere Streamlit supports Markdown by using the color-badge Markdown directive. See st.markdown for more information.
Function signature[source] | |
---|---|
st.badge(label, *, icon=None, color="blue") | |
Parameters | |
label (str) | The label to display in the badge. The label can optionally contain GitHub-flavored Markdown of the following types: Bold, Italics, Strikethroughs, Inline Code. See the body parameter of st.markdown for additional, supported Markdown directives. Because this command escapes square brackets ([ ]) in this parameter, any directive requiring square brackets is not supported. |
icon (str or None) | An optional emoji or icon to display next to the badge label. If icon is None (default), no icon is displayed. If icon is a string, the following options are valid:
|
color (str) | The color to use for the badge. This defaults to "blue". This can be one of the following supported colors: blue, green, orange, red, violet, gray/grey, or primary. If you use "primary", Streamlit will use the default primary accent color unless you set the theme.primaryColor configuration option. |
Examples
Create standalone badges with st.badge (with or without icons). If you want to have multiple, side-by-side badges, you can use the Markdown directive in st.markdown.
Still have questions?
Our forums are full of helpful information and Streamlit experts.