Change container layout with screen width

Hi guys,

I have one input field “a” within a container R that has a row layout.
For tablet/mobile devices, I created a container C which is similar to container R, but with a column layout.
In container C, I therefore have one input field “b” similar to “a”.

My first question is: while dealing with container layout, is it the only way to have different layouts? Because it seems this property is not changeable in the element condition “when…”.

My second question is: how do you sync “a” with “b”? if a user type “test” in the input “a”, and changes his browser screen width until reaching my tablet breakpoint, then input “a” will be replaced by input “b”. So input “b” must have the value of a so that the user doesn’t notice something has changed.

To answer the second question, I did the steps below:

  • create an intermediary variable “v”
  • set the “default value”/“initial content” properties of “a” and “b” to equal “v”
  • whenever input “a” changes, display data with input a value in “v” and reset input “b”
  • whenever input “b” changes, display data with input a value in “v” and reset input “a”

This worked, but I was quite surprised I needed all these steps and thought there might be something much simpler.

Looking forward to hearing to different approaches :slight_smile:

Hi @nassmim972 ,

Elements within a row container automatically stack vertically when their minimum width is attained. Additionally, you can use min / max width inside conditionals to “force” stacking at specific page widths. And while the container type itself can’t be changed conditionally, there are numerous techniques for altering layout using the various container types - especially when different container types are nested.

The way you’re going about it by duplicating elements, etc. is going to be a nightmare to maintain - especially as your app grows in size and complexity.

I would encourage you to check out the many educational resources for working with Bubble’s layout engine. A good place to start is with Bubble’s own written and video lessons…

Good luck!

1 Like

thanks for the approach @sudsy I’ll try this way on my next work and see how it goes!