Clear the text in text_input

I can get the text entered by a user for streamlit.text_input.

Is there a way to empty the text that was entered? It seems that I can only set the text in text_input when I first declared it like streamlit.text_input(‘Text’, ‘My Text’).

Thanks.

Hi @demoacct,

Looks like we still have an open documentation issue around this! Thanks for the reminder. :smiley:

Check out the techniques discussed in the above issue thread and see if one of the ideas – e.g. using a button to reset the input – will work for you.

Thanks!

Hello, I got the same issue.

I type in a text (to be interpreted as a command) into the text_input that should be cleared after the execution, so that I can type in the next “command” without having to delete the previous one.

An additional button does not really make sense for that purpose.

It’s strange that this is still an issue, as it seems like such a basic need. If I have a text input:

search_query = st.sidebar.text_input("Search")

Why can’t I in my script say

search_query = ""

to reset it?

1 Like