question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation needed around manipulating st.text_input elements

See original GitHub issue

I couldn’t find on the docs how to reset a st.text_input.

By reset, I mean the user fill the text_input, do other things… And when clicking a “Finish” button, the text_input is reset to its default value.

How can I achieve this ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
jrhonecommented, Nov 8, 2019

Hey @Colanim

Here’s a workaround that will allow you to reset the widget value without using an empty space as the value. It also works OK in the sidebar.

We’ll be using a SessionState class which is kind of a hack at the moment. Find the code for SessionState at this gist, https://gist.github.com/tvst/036da038ab3e999a64497f42de966a92

import streamlit as st
import SessionState


state = SessionState.get(key=0)

ta_placeholder = st.empty()

if st.button('Clear'):
    state.key += 1

x = ta_placeholder.text_area('Some text', value='', key=state.key)

x

We’re currently working on some ideas on how to improve this!

2reactions
sumitkuttycommented, Mar 25, 2021

Was this solved? I wanted the clear the input_text() area for a chatbot after the response is received. Does someone know how to do that?

Read more comments on GitHub >

github_iconTop Results From Across the Web

st.text_input - Streamlit Docs
st.text_input displays a single-line text input widget. ... supports the following elements: Bold, Italics, Strikethroughs, Inline Code, Emojis, and Links.
Read more >
<input type="text"> - HTML: HyperText Markup Language | MDN
<input> elements of type text create basic, single-line inputs. You should use them anywhere you want the user to enter a single-line value...
Read more >
Labeling Controls | Web Accessibility Initiative (WAI) - W3C
Provide labels to identify all form controls, including text fields, checkboxes, radio buttons, and drop-down menus. In most cases, this is done by...
Read more >
TextInput - React Native
TextInput. A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >
type - Cypress Documentation
The text to be typed into the DOM element. Text passed to .type() may include any of the special character sequences below. These...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found