How to create text output box

I imagine this is a pretty simple question but how do I create a text output box on my app?

I want to take text input from the user (I am using this: user_input = st.text_area(“Type or paste text below:”), apply a transformer model to it, and have the output from the model displayed back to the user in a “st.text_area” style box.

Hi @Buckeyes2019, welcome to the Streamlit community!

Not sure what you are asking here…are you looking for how to style the output so that it looks like the input box, or actually put the output into a new text_area box?


Please disregard! I figured it out (just put the variable in a st.text_area). Thanks!

Can you share how did you get the text output in a text_area field? I’m trying to get the output of text summarization model (transformers) in the text_area but it always displays the summarized text first, then a text_area pops up below it.

Here is the code I used for my app:

if option == ‘Text Summarization’:

max_lengthy = st.slider('Maximum summary length (words)', min_value=30, max_value=150, value=60, step=10)

num_beamer = st.slider('Speed vs quality of summary (1 is fastest)', min_value=1, max_value=8, value=4, step=1)

text = st.text_area('Enter Text Below (maximum 800 words):', height=300) 

submit = st.button('Generate')  

if submit:


    with st.spinner(text="This may take a moment..."):

        summWords = sum2(text, max_length=max_lengthy, min_length=15, num_beams=num_beamer, do_sample=True, early_stopping=True, repetition_penalty=1.5, length_penalty=1.5)

    text2 =summWords[0]["summary_text"]


Thanks for the answer. My question is, is there a way to get the output of your summarized text in a text_area field?

I just put it in:

I did not end up using: st.text_area()

Ahh…No issue. Thanks for replying :slightly_smiling_face:

Pretty simple to get text output box with your model output/result :

input = st.text_area(“Give Your Input”,"",height =20)
modelresponse = model_function(input)
st.text_area(label ="",value=modelresponse, height =100)

outputs result into text output box using text_area

Hope it helps. Thanks to Streamlit Community for this forum to ask and solve questions.

1 Like

st.text_area("Summarized Text", text2)

This should put your output summarized text in a text box.