Search code examples
layouttextareaheightipywidgetsvoila

ipywidgets Textarea height='auto' does not work


I am using ipywidgets to create a Dashboard with voila

I have a Textarea as follows:

comm_text = widgets.Textarea(value='',
                            placeholder='OK',
                            description='',
                            style=style,
                            layout=widgets.Layout(height="auto", width="auto"))

what I pretend with height="auto" is that when entering lines in textarea the text box expands vertically accordingly. (I want to have all the text visible)

It actually does not happend. As you can see in the screenshot I introduced 8 lines but the textarea does not expand along.

Is that at all possible? If not, what does actually height="auto" stand for?

out


Solution

  • If you change

    layout=widgets.Layout(height="auto", width="auto")
    

    for

    layout=widgets.Layout(height="100%", width="auto")
    

    It will resize to display all the text that it had on the value (default value for the Textarea).

    enter image description here

    However it won't grow as you type. I don't remember any textarea that does that on webpages.

    One more thing. If you are using grids, with height="auto" and you resize the Textarea (dragging by the corner), it will resize other related elements of the grid.

    enter image description here

    That won't happen if you use height="100%"