How to display editable text to the user

Hi, I want to display some text to the users and let them edit it. now I’m using:

            text = st.text_input("Comments:", placeholder="Some long comment to edit")
            st.button("Submit", on_click=handler_func)

But this way the text is only displayed when nothing else is typed, and the user input overrides the placeholder. Is there a way to display the text and let the user edit it without deleting it?

Thanks!

Hey @lilache,

If you just want to set a default and let them edit different parts you can try switching placeholder to value:

text = st.text_input("Comments:", value="Some long comment to edit")

If you’re looking for overwrite mode like with an insert key that will be a bit more funky, I found a stackoverflow answer with an interesting method for that.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.