reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Width of input can't be set within a vstack.

Open hjpr opened this issue 1 year ago β€’ 6 comments
trafficstars

Setting width of a high level input component from within an vstack or other non radix container will not change width of input component. Changing the container to a flex allows input width to be 100% or set manually.

Specifics (please complete the following information):

  • Python Version: 3.11
  • Reflex Version: 0.4.4
  • OS: Ubuntu 23.10

hjpr avatar Mar 14 '24 19:03 hjpr

Could you share a reproducible example ?

wassafshahzad avatar Mar 17 '24 23:03 wassafshahzad

def example() -> rx.Component:
    return rx.vstack(
        rx.input(
            placeholder='Test Example',
            width='100%'
        )
    )

Above is an approximate of how I discovered it. If you wrap in flex instead, the width is set appropriately. The rendered code appears to not carry width as a CSS prop assigned to input using vstack, but does carry using flex container.

hjpr avatar Mar 18 '24 00:03 hjpr

I looked into the issue using the following code

def index() -> rx.Component:
    return rx.vstack(
        rx.input(
            placeholder='Test Example',
            width='100%'
        )
    )

We get vstacck_input

While using the following code

def index() -> rx.Component:
    return rx.flex(
        rx.input(
            placeholder='Test Example',
            width='100%'
        )
    )

We get flex_inut

I both cases the input tag does have the width property although The TextFieldRoot does not and it seems to be consistent in both flex and vstack.

wassafshahzad avatar Mar 18 '24 23:03 wassafshahzad

vstack inherit from flex so it's expected to have same behaviour in both.

Lendemor avatar Mar 18 '24 23:03 Lendemor

Any workaround for this limitation?

spac3-monk3y avatar Apr 18 '24 18:04 spac3-monk3y

The workaround is to set the width in units or to set the 100% width on the rx.input.root

rx.input.root(
    rx.input(),
    width="100%",
)

I hear this is one of things that is fixed in radix 3.0.0 which we'll be upgrading to soon.

masenf avatar Apr 18 '24 18:04 masenf

We've upgraded our input component, so this should work now with needing rx.input.root.

picklelo avatar Jun 03 '24 02:06 picklelo