Long text, need to adjust width

Currently, when text is long, it choose to use a horizontal scroll bar which is very weird. While using text_area the text would behavior much better except that I don’t really need the area for typing text.

import streamlit

string = "TEXT BOX IS NOT WIDE ENOUGH " * 10
streamlit.text(string)

streamlit.text_area(string)

Hey @noklam and welcome to the community :blush:,

If I understand correctly, you are saying that a script like the one below results in annoying horizontal scrolling inside the text widget:


st.text_input("Enter some text", "long " * 30 + "text")

…and to solve this I assume you would like to make the text widget grow vertically as needed, as you add more text.

Is this correct?

That’s an interesting feature request, but it’s not very high on our priority list at this time. That said, if someone from the community is reading this and would like to implement this behavior, please contact us! This would be a perfect first contribution, given its very clear scope :smiley:

2 Likes

I am facing the same issue while displaying the text output on my Bert Text Summarizer App. The feature to solve this issue should be on the priority as displaying text is the most common operation in any kind of development.

@Huzmorgoth

TIP: Use st.markdown or st.write instead of st.text for long texts :slight_smile:

Try:

import streamlit as st

loooong_text = ' '.join(["abcd efg hijk lmnop lmnop qrst uvw xyz"]*1_000)

st.text("st.text: " +  loooong_text)

st.markdown("st.markdown : " + loooong_text)