Issue: Streamlit text_input with random placeholder not displaying user input
I am having an issue with my Streamlit app where the user input is not displaying correctly when using a random placeholder. If I use a static placeholder, it works fine. However, when I switch to a random placeholder, the input field does not show the entered text.
Here’s my code:
import streamlit as st
import random
placeholders = ["Enter your name", "Type your message", "Say something", "What's on your mind?"]
# Get user input with a random placeholder
user_input = st.text_input("Enter your input:", placeholder=random.choice(placeholders), key='name')
# Create a button to print the user input
if st.button("Greet"):
if user_input:
st.write(f"Hello, {user_input}")
else:
st.write("please enter input")
Current Output:
please enter input
Expected Output:
Hello, [user input]
Has anyone faced a similar issue or can suggest a workaround to use random placeholders for user input in Streamlit?
Thanks in advance!
Debug info:
streamlit==1.37.0
Python 3.11.7
3