st.button("Click ME - " + str(i+1))
How do I add a emoji in my button?
st.button("Click ME - " + str(i+1))
How do I add a emoji in my button?
Hi @Hiba_Fatima
You should be able to copy+paste your favorite emojis to the label
argument for st.button
like so:
import streamlit
st.button("Click Me 👈")
I’ve used sites like Get Emoji and Emoji Finder search for emojis.
Here’s a fun, reproducible example where the emoji used in st.button
updates with every click. It makes use of Streamlit’s Session State API and callbacks:
import streamlit as st
import random
# callback to update emojis in Session State
# in response to the on_click event
def random_emoji():
st.session_state.emoji = random.choice(emojis)
# initialize emoji as a Session State variable
if "emoji" not in st.session_state:
st.session_state.emoji = "👈"
emojis = ["🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼"]
st.button(f"Click Me {st.session_state.emoji}", on_click=random_emoji)
Happy Streamlit’ing!
Snehan
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.
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.
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.
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.