Search code examples
pythonvuetify.jsipyvuetify

ipyvuetify: How to limit width of TextField


I am trying to have an ipyvuetify Textfield for setting a one-digit number, but cannot limit the with of the text field to anything reasonable. A simple spinet of code e.g.

import ipyvuetify as v
#Textfield should be an one digit number...
v.Row(children=[v.TextField(type="number"), v.Html(tag='H1',children=['Some text here'])])

results to a huge TextField that looks ugly: enter image description here

How can I set the some limit to the width of the TextField / set it so that it has max width of one character? Alternatively, is there any property I can set on vue v-TextField / vue code that would limit the size of the TextField ?


Solution

  • Adding a max-width:50px to the TextField style works.

    import ipyvuetify as v
    text_field_widget = v.TextField( style_ = "max-width:50px", v_model=None, type="number")
    #Textfield should be an one digit number...
    row = v.Row(class_ = 'mx-2',children=[text_field_widget, v.Html(tag='H1',children=['Some text here'])])
    row
    

    enter image description here