gradio icon indicating copy to clipboard operation
gradio copied to clipboard

Can gradio add a vertical scrollbar to the textbox?

Open yiya1989 opened this issue 1 year ago • 9 comments

  • [x] I have searched to see if a similar issue already exists. https://github.com/gradio-app/gradio/issues/6977 But this issue has been closed

Is your feature request related to a problem? Please describe.
When my text is too lang, it's hard to view all the txt because the Textbox has no vertical scrollbar .

Describe the solution you'd like
Add a vertical scrollbar to the left Textbox.

Additional context
Like this issue said: Add a scrollbar to notebook/default textboxes

image

yiya1989 avatar May 13 '24 15:05 yiya1989

Hi @yiya1989 you should already be able to scroll the textbox if it grows too long. The scrollbar is not needed and from a design perspective, we've opted out of adding it by default. If you'd like to add it, I'd suggest using custom css, as was done in the linked PR: https://github.com/oobabooga/text-generation-webui/commit/6afc1a193bb1d68deccd569c89d70ee9bf35246c

abidlabs avatar May 13 '24 19:05 abidlabs

Hi @yiya1989 you should already be able to scroll the textbox if it grows too long. The scrollbar is not needed and from a design perspective, we've opted out of adding it by default. If you'd like to add it, I'd suggest using custom css, as was done in the linked PR: oobabooga/text-generation-webui@6afc1a1

@abidlabs Hello! When the txt is 50 lines and the Textbox limit max 20 lines, it is useful to just scroll the textbox as the default. But when the txt lines reach to 500 lines, It's necessary to has a vertical scrollbar. Can we has a default vertical scrollbar which can control by a switch default False? Just like current github textbox editor, it also has the vertical scrollbar.

yiya1989 avatar May 14 '24 00:05 yiya1989

+1

umarbutler avatar Nov 25 '24 02:11 umarbutler

+1

bryanlan avatar Dec 17 '24 13:12 bryanlan

is there any progress on this topic? I'm building a simulated terminal and scrollbar is a must. an attribute like show_scrollbar=True or else. is anyone has a temporary solution? thanks in advance

ROBERT-MCDOWELL avatar Jan 11 '25 13:01 ROBERT-MCDOWELL

As far as I know, starting from version 3, Gradio's textbox no longer displays a scrollbar. I'm not sure why they insist on this—perhaps it's for aesthetic reasons? When the content is only a few dozen lines, the presence or absence of a scrollbar doesn't really matter. But when dealing with hundreds of lines, having a scrollbar makes a big difference.

Below is my solution, which also uses CSS to handle it.

css = """
textarea[rows]:not([rows="1"]) {
    overflow-y: auto !important;
    scrollbar-width: thin !important;
}
textarea[rows]:not([rows="1"])::-webkit-scrollbar {
    all: initial !important;
    background: #f1f1f1 !important;
}
textarea[rows]:not([rows="1"])::-webkit-scrollbar-thumb {
    all: initial !important;
    background: #a8a8a8 !important;
}
"""

with gr.Blocks(css=css) as demo:
...

This CSS modifies the default style of multi-line textareas.

avan06 avatar May 03 '25 06:05 avan06

As far as I know, starting from version 3, Gradio's textbox no longer displays a scrollbar. I'm not sure why they insist on this—perhaps it's for aesthetic reasons? When the content is only a few dozen lines, the presence or absence of a scrollbar doesn't really matter. But when dealing with hundreds of lines, having a scrollbar makes a big difference.

Below is my solution, which also uses CSS to handle it.

css = """ textarea[rows]:not([rows="1"]) { overflow-y: auto !important; scrollbar-width: thin !important; } textarea[rows]:not([rows="1"])::-webkit-scrollbar { all: initial !important; background: #f1f1f1 !important; } textarea[rows]:not([rows="1"])::-webkit-scrollbar-thumb { all: initial !important; background: #a8a8a8 !important; } """

with gr.Blocks(css=css) as demo: ... This CSS modifies the default style of multi-line textareas.

yes, we can only add css to support scrollbar, but it's more convenient to has a an attribute like show_scrollbar=True.

yiya1989 avatar May 03 '25 06:05 yiya1989

I strongly agree with @yiya1989 . Adding a vertical scrollbar to the Textbox component would greatly enhance usability, especially when handling large volumes of text.

ypzpro avatar May 13 '25 04:05 ypzpro

+1

ROBERT-MCDOWELL avatar Jun 03 '25 01:06 ROBERT-MCDOWELL