Scrolling text containers

Hey all,

I have a super long text stream and it needs to only take up an NxM pixel area. It would work just fine if I could put it inside a container that can scroll but I haven’t found a solution yet.

I saw this post but I don’t understand the solution. Is there a better way to get a text area that can scroll?


From what I understand, you could do inspect element for a specific part of the web page and grab the element class for you to apply the CSS styling needed. In this case, once you identified the class, you can add overflow: scroll. Hope this can lead you to the solution as my understanding of this is also quite shallow.

1 Like

Hi all, did anyone find the solution to this? Thanks in advance.

One option is with components, like this:

import streamlit as st
from streamlit.components.v1 import html

lorem = (
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod, nisl nec
vulputate lacinia, nunc nisl aliquam mauris, eget aliquet nisl nisl et nunc.
Sed euismod, nisl nec vulputate lacinia, nunc nisl aliquam mauris, eget aliquet.</p>
    * 10

html(lorem, height=100, scrolling=True)

This works but the output is not desirable if one wishes to use a custom theme


There is a dedicated third party streamlit-scrollable-textbox component that works perfectly for this purpose (even with custom theme)


pip install streamlit-scrollable-textbox

Sample Usage Code:

import streamlit_scrollable_textbox as stx

long_text = "Input here"
stx.scrollableTextbox(long_text,height = 300)

Demo in a real world application

(From my AI AudioTranscriber MVP)

1 Like