Streaming text_area / text_input

I’d love to do projects involving visualizations that change dynamically as you type.

Is there any way to get the text_area or text_input widgets to stream their text to Python as they’re being modified without requiring the user to explicitly press enter or ctrl+enter?

1 Like

I would also like to know this.

I see this as one of the fundamental challenges of the Streamlit architecture of running the script top to bottom. I believe this architecture would make it too slow in practice compared to other analytics apps frameworks that use callbacks and updates small parts of the application.

Would love to learn and be proved wrong.

@DavidHolz. I belive the way to currently go is a creating a Custom Streamlit Compont and see if that would work satisfactorily.

1 Like

Welcome to the community @DavidHolz

I second @Marc on this, a Streamlit component bringing a text input with a onchange event handler should do. I tried to condense all of component creation in this tutorial if you want to have a try poking with frontend, or the template if you already have small experience with JS/Node.

Could not find a post about this in the forum, but I regularly see this on Twitter so I think it would deserve its own thread :slight_smile:

2 Likes

Hello @DavidHolz,

If you want to test this refresh as you type workflow with an already existing solution, you could try to use my Ace Editor component. It updates the app every 200ms as you type (this value is hardcoded in my component code for now though).

If results are good, I suggest you follow @andfanilo’s tutorial to build a simpler/lighter component for your purpose.

3 Likes